Perform the following tasks (label cells as task numbers). Note the first cell (unnumbered) should start with the identification “LAB 1” followed by yourFull Name and section number. Example:
%% Lab 1 by Your_Name_Here Section 61 or 62
In this first lab, you will create some fun-looking Lissajous figures. This will give you an opportunity to learn some basic MATLAB skills and commands.
- Open MATLAB and create a new script file. You can either use the keyboard shortcut (Command or control +N) or do this by clicking the gold + icon in the upper left portion of the MATLAB window. Add your name and other info, after first typing %% to start a new section in the script.
You can create a vector of time values using the notation:
>> t = start : step : stop
>> t = 0 : 2 : 10
0 2 4 6 8 10
Notice the values are printed to the screen. This can be a problem if you are plotting points and hundreds of numbers clutter your screen. To suppress such unwanted output, terminate the line with a semi-colon.
>> t = 0 : 2 : 10;
Question 1: Create a new section using %%, and generate a vector t of numbers from 0 to 2π using a step-size of 0.01 You can find π by typing pi
Use the size command to find the exact number of points in your time vector t.
You can learn more about this command by typing:
>> help size
Create the following outputs using proper Matlab syntax. This assumes the vector t has already been defined.
Using subplot, plot: y1(t) vs t, y2(t) vs t and y2(t) vs y1(t). You should be able to get a tiled plot similar to that shown below, but which uses different constants. Your graphs will be slightly different!Here is some code to get you started with the first tile. (Assumes the time vector has already been entered.)
y1 = sin(5*t);
plot(t, y1, ‘r’, ‘LineWidth’, 2)
axis([0 2*pi -1 1])
Replace the tiled plot below with your final plot for four points.
The graph below is for and instead.
Question 6:What happens to the Lissajous curve if both of the arguments to the sine and cosine waves double?
Question7: What shape is the Lissajous curve if instead: and ?
Notice, the constants are the same.
Question8: What shape is the Lissajous curve if instead: and ?
Questions 9 and 10:Just for fun, run the code in the file Lissajous_fun.m that is based on code written by Nick Trefethen. It uses some advanced notions that you need not master at this stage. Run the file a few times, trying different parameter values in the last section with the 3D cube. Then paste in your favorite “Cube with Lissajous Faces” image.
Paste 3D cube here.