Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

EECS 1011 – Lab05 : If Statements + Lego Drawing This document is copyright Babak Tavakoli-Gheynani; you may use it in the context of your studies at York University; you may not distribute it outside...

1 answer below »
EECS 1011 – Lab05 : If Statements + Lego Drawing
This document is copyright Babak Tavakoli-Gheynani; you may use it in the context of your studies at York University; you may not distribute it
outside of York University.
Page 1 of 4
EECS 1011 – Lab05: If Statements + Lego Drawing


Summary: Draw isometric images and then use a conditional statement (“if”) to select between
one configuration and another in MATLAB..

Pre-Lab:
Do the following before the lab:
1) Print off two (or more) sheets of isometric paper.
2) Review the class notes for if statements (Lec07-Feb01 & Lec08-Feb03), you can also .
3) Watch the YouTube video on drawing a robot (sketching & MATLAB). This is from the old
version of the lab (pre-COVID), but the demonstration can help you here.

Intro:
The lab is divided up into four parts:
Part 1: Practice writing a simple function that accepts input and writes to the screen.
Part 2: Practice an if-elseif-else structure within a function.
Part 3: Draw a multiple Lego using patches.
Part 4: Use if-elseif-else to choose whether to add a new block to your Lego image.



Figure 1. An example of the Lego block a
angement that you'll draw. A one-by-four block is assumed to be one unit wide, one
unit high and four units long.

Lab Instructions

Part 1: Create a function in a MATLAB script (.m file) that incorporates a user input (from the
Command Window) and creates plots based on what the user input. Look at the following as an
example of a file that has the same name as the function that is written in the MATLAB editor.
Notice how it has an input variable (in parentheses) and that I can call the function from the
command window, with a value for that input variable.

http:
lrt.ednet.ns.ca/PD/BLM/pdf_files/dot_pape
iso_dot_1cm.pdf
https:
www.youtube.com/watch?v=l1z6JNVhNmQ&feature=youtu.be
EECS 1011 – Lab05 : If Statements + Lego Drawing
This document is copyright Babak Tavakoli-Gheynani; you may use it in the context of your studies at York University; you may not distribute it
outside of York University.
Page 2 of 4

Figure 2. A function defined in the editor and called from the command window. Note that the file name and function name are
the same. They have to be! Do something similar for this part of the lab.

Part 2: Type in the following code for the if-elseif statement. Try it out from the Command
Window. See if you can make the different plots show up via commands from the Command
Window.


Figure 3. Example if-elseif MATLAB script called mynewprogram.m. You call the function from the command window in MATLAB:
mynewprogram(2) [Enter]
EECS 1011 – Lab05 : If Statements + Lego Drawing
This document is copyright Babak Tavakoli-Gheynani; you may use it in the context of your studies at York University; you may not distribute it
outside of York University.
Page 3 of 4
Part 3: Draw the Lego blocks in MATLAB
Look at the below table that shows you a particular configuration of the Lego that you should
draw. The configurations are specific to your name. Sketch the Lego by hand using isometric dot
paper. Leave enough space for a second sketch from Part 4, beside the first one. Include the
pictures of the Lego setup and your drawing in your report.

Last Name: A-J Last Name: K-R Last Name: S-Z


Now draw the Lego using MATLAB. Refer to the posted video that describes how to do this using
the Patch function in MATLAB. The video describes a more difficult task of drawing in MATLAB…
the Lego blocks are easier.

Remember that we consider the mapping of the Lego blocks to be as follows: for a one-by-four
lock, it’s one unit wide, one unit high and four units deep. One unit co
esponds to the space
etween two dots in the isometric paper and the distance between whole numbers (1 and 2 or
15 and 16, for instance) in MATLAB.

Make sure to use the following two commands to get the axis proportions co
ect and to get the
automatic orientation of the shape (view from above and to the side: i.e. “three-quarter view”):



Part 4: Change the Lego drawing in MATLAB using a conditional statement
Create a function file called “mylegodrawing.m” in MATLAB that accepts input from the
command line. You will draw the Lego blocks from Part 3 if the user enters

on the other hand, if the user enters

then you should draw the shape which applies to you in the table. Note that you don’t need to
draw the flat 4 by 6 black plate… we use it for reference and to hold your
icks together.

Last Name: A-J Last Name: K-R Last Name: S-Z


EECS 1011 – Lab05 : If Statements + Lego Drawing
This document is copyright Babak Tavakoli-Gheynani; you may use it in the context of your studies at York University; you may not distribute it
outside of York University.
Page 4 of 4

Finally, if the user enters any other number (other than 5 or 3), then draw the Lego blocks entirely
in black, using the shape from Part 3.

Hint: Consider inserting the following code within the “if”, “elseif”, and “else” sections of your
code, just before you call the “patch” function, as it will clear the figure and orient it properly:



Make sure that your TA verifies Part 4 before you leave the lab session.

Writing a Report
Submit a standard report, as shown below. Make sure to include all images from Parts 3 and 4
Only submit a PDF file to the eclass.yorku.ca site. Mac OS X, Windows 10 and Linux all support
“printing to PDF” natively. For older Windows machines use the free PDFCreator.


Figure 4. Example layout of a lab report. label everything so that your TA knows what to mark.

Due date for Lab Report: The reports are all due on Sunday, Feb. 14 at 11:59pm. Submit
eport to the eClass server at eclass.yorku.ca.


https:
sourceforge.net/projects/pdfcreato
Answered 2 days After Feb 13, 2021

Solution

Rahul answered on Feb 15 2021
143 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here