EGR 101 MATLAB Exam with all Correct & 100%
Verified Answers |Actual Complete Exam |Already
Graded A+
True/False: Arrays in MATLAB can only be one dimensional. ✔Correct Answer-False
You want to create an array
(stored in x) that starts at 1 and ends at 40 with 100 data points. What line of code would you use?
✔Correct Answer-x = linspace(1, 40, 100)
You want to create the following array:
x=[2 4 6 8 10 12 14 16]
What line of code would you use? ✔Correct Answer-x=[2:2:16]
What command would you use to return the 5th element in the following array?
array = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]; ✔Correct Answer-array(5)
Given the following code:
x=[-15 20 -13 -19 3 16 7 -13 -5 -2];
z=x(6);
What is stored in z? ✔Correct Answer-16
Given the following code:
x=[ 20 -14 15 6 -5 -13 -3 -1 -16 4];
z=x(2);
What is stored in z? ✔Correct Answer--14
Given the following code:
x=[ -11 -5 3 -10 -9 5 -10 13 20 9];
, [Y, K]=min(x)
What is stored in Y? ✔Correct Answer--11
Given the following code:
x=[ -11 -5 3 -10 -9 5 -10 13 20 9];
[Y, K]=max(x)
What is stored in K? ✔Correct Answer-9
True/False: Linspace is most useful for creating arrays when you want to control the number of data
points generated. ✔Correct Answer-True
True/False: All conditional statements must use the word "end" to complete the statement.
✔Correct Answer-True
Given the following lines of code, what value is stored in the variable z?
x = 3;
y = 4;
z = 5;
if (y > x)
z = z + 1;
else
z = z - 1;
end ✔Correct Answer-6
Given the following lines of code, what value is stored in the variable z?
x = 3;
y = 4;
z = 5;
if (2*x < y)
z = z + 1;
Verified Answers |Actual Complete Exam |Already
Graded A+
True/False: Arrays in MATLAB can only be one dimensional. ✔Correct Answer-False
You want to create an array
(stored in x) that starts at 1 and ends at 40 with 100 data points. What line of code would you use?
✔Correct Answer-x = linspace(1, 40, 100)
You want to create the following array:
x=[2 4 6 8 10 12 14 16]
What line of code would you use? ✔Correct Answer-x=[2:2:16]
What command would you use to return the 5th element in the following array?
array = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]; ✔Correct Answer-array(5)
Given the following code:
x=[-15 20 -13 -19 3 16 7 -13 -5 -2];
z=x(6);
What is stored in z? ✔Correct Answer-16
Given the following code:
x=[ 20 -14 15 6 -5 -13 -3 -1 -16 4];
z=x(2);
What is stored in z? ✔Correct Answer--14
Given the following code:
x=[ -11 -5 3 -10 -9 5 -10 13 20 9];
, [Y, K]=min(x)
What is stored in Y? ✔Correct Answer--11
Given the following code:
x=[ -11 -5 3 -10 -9 5 -10 13 20 9];
[Y, K]=max(x)
What is stored in K? ✔Correct Answer-9
True/False: Linspace is most useful for creating arrays when you want to control the number of data
points generated. ✔Correct Answer-True
True/False: All conditional statements must use the word "end" to complete the statement.
✔Correct Answer-True
Given the following lines of code, what value is stored in the variable z?
x = 3;
y = 4;
z = 5;
if (y > x)
z = z + 1;
else
z = z - 1;
end ✔Correct Answer-6
Given the following lines of code, what value is stored in the variable z?
x = 3;
y = 4;
z = 5;
if (2*x < y)
z = z + 1;