Access over 35 million academic & study documents

Mat Hw4

Content type
User Generated
Subject
Engineering
Type
Homework
Rating
Showing Page:
1/10

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/10

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/10

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 10 pages?
Access Now
Unformatted Attachment Preview
Answer of problem (1) Matlab script code: % Answer of question (1) clc clear disp ( 'Problem 1' ) a = 6; b = 2; c = -5; disp('(a)') x1=a+b; x2=a-b; ya = x1>x2< c disp('(b)') yb = - 6 < c < -2 disp ('(c)') x1 = a / b; x2 = b + c; yc = (x2 >= c)&&(c > x1) disp ('(d)') x1 =c+a; x2 =(a/b)- b; x3 =( x1 ~= x2 ) %x1=a+c=c+a yd = x1 ==~ x3 disp('******************************************') %**************************************************** Results from the command window: ****************************************************************************** Answer of problem (2) Matlab script code: % Problem 2 disp ( 'Problem 2' ) disp('(a)') a=0 & 21 disp('(b)') x1=~-2 >-1 ; x2= 11>= ~0; b=x1&x2 disp('(c)') x1=4-(7/2); x2= 6 < 5 | -3; c=x1 & x2 disp ( '(d)' ) x= -1 & ~2 * -3; d= 3| x | 0 disp('******************************************') %**************************************************** Results from the command window: ****************************************************************************** Answer of problem (3) Matlab Function code: function [P N]= NegPosSort(x) % Input variable is X %Output variables are P for positive and N for negative N=0; P=0; m=0; k=0; n=length(x); for a=1:n if ( x(a) < 0 ) m=m+1; N(m) = x(a); elseif (x(a)>0) k=k+1; P(k) = x(a); end end end Matlab script code: % Problem 3 disp ( 'Problem 3' ) x=[ -3.5 -5 6.2 11 0 8.1 -9 0 3 -1 3 2.5 ]; [ N P ] = NegPosSort ( x ) disp('******************************************') %****************************** ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Awesome! Perfect study aid.

Studypool
4.7
Indeed
4.5
Sitejabber
4.4

Similar Documents