Computer Question 1:
Subplot
Write Matlab code
that does the following:
1) Begins by setting
A
= [ 1:10 ; 31:40 ; 26:2:44 ];
2)
Then, your program should calculate the sum of each row of
A
.
If, and only if, the sum of any of the rows of the matrix
A
is at least 350, your
program should display the following two graphs next to each other using
subplot, with x containing 243 points running from 1 to 20.:
y = x
3
+ 2x
y = x
4
- 10000 sin(x)
Your graph should look like this:
s = sum(A');
if
(sum(s>=350))
% another possibility: if(max(s)>=350)
x = linspace(1,20,243);
subplot(1,2,1);plot(x,x.^3 + 2*x);
subplot(1,2,2);plot(x,x.^4-10000*sin(x));
end
-4 if they have minor syntax errors (they had the computer to check answers)
-6 if they don’t have the if statement’s condition correct, but successfully use
subplot, plot, and linspace
-8 if they at least successfully use 2 of the following: subplot, plot, and linspace
-10 if they at least successfully use 1 of the following: subplot, plot, and linspace
-12 if they seem to kind of understand how to plot things
-14 otherwise
Computer Question 2:
Class Grades
Run the following commands, which create a 100 element row vector
b
:
rand( 'state' , 4 ) ;
b = round( 100*rand(1,100) - 10 );
class = ‘Matlab’;