You are on page 1of 2

12/24/2019 Lab 5 (review) (Thu): Attempt review

Dashboard / My courses / LE/EECS1560 A - Introduction to Computing for Mathematics and Statistics (Fall 2019-2020)
/ Lab 5 (Review) Material / Lab 5 (review) (Thu)

Started on Thursday, 10 October 2019, 1:00 PM


State Finished
Completed on Thursday, 10 October 2019, 3:28 PM
Time taken 2 hours 28 mins
Grade Not yet graded

Question 1 Create a script called piecepyramid.m that computes a function Y(X) which is zero for X<-1, X+1 for -1<=X<0, -X+1 for 0<=X<1
Complete and zero for X=>1. The script assumes that variable X is defined and assigns the value of the function to variable Y. To test
Marked out of it assign values to X in the various intervals and see if Y has the correct value after executing the script.
1.00

piecepyramid.m

Here is the solution.

Question 2 Create a script called pyramid.m that plots a function Y(X) which is zero for X<-1, X+1 for -1<=X<0, -X+1 for 0<=X<1 and zero
Complete for X>=1. Plot it using 150 points and a range from -2 ... 2. Do not use a for loop.To do this create a vector X with the
Marked out of appropriate range and number of elements and compute the corresponding Y. To get an idea, try to plot (X>0) or (X>0).*
1.00 (X<1) or (X>0).*X.

pyramid.m

Here is the solution.

Question 3
Write a short script named centerplot.m that plots a vector Y. Normally this is done with plot(Y). But if the vector has N
Complete
elements the plot will be from 0 to N. For this script we want to plot from -N/2 to N/2.
Marked out of
1.00

centerplot.m

The solution is here

Question 4
Consider the code
Complete
X0=[1,1];
Marked out of
1.00 X1=conv(X0,X0);
X2=conv(X1,X1);
X3=conv(X2,X2);
Write a script named multiconv.m to plot all these vectors X0, X1, etc on the same plot, all centred using the script
centerplot.m from the previous question. If you do not know what function conv does, do not worry. We will cover it later
in the course.

multiconv.m

The solution is here

https://moodle.yorku.ca/moodle/mod/quiz/review.php?attempt=2456399&cmid=2191841 1/2
12/24/2019 Lab 5 (review) (Thu): Attempt review

Question 5
Write a script named PrettyMat.m that writes into a file named PrettyMat.csv a matrix with three rows and many columns.
Complete
Every row is in a separate line and every element except the last is followed by a comma and a space. There should be two
Marked out of
1.00 digits after the decimal point.

PrettyMat.m

The solution is here

◄ Lab 5 (review) (Tue) Jump to... Lecture Notes and Examples ►

https://moodle.yorku.ca/moodle/mod/quiz/review.php?attempt=2456399&cmid=2191841 2/2

You might also like