Suppose that x 10 2 6 5 3 and y 9 3 2 5 1 find the results

Suppose that x =[10, -2, 6, 5 -3] and y = [9, -3 2, 5 -1] .find the results of the following operations by hand and use MATLAB to check your results z= (x less than 6) z= z=(x is equlto y) z= z = (x== y) z= z=(x = y) z=

Solution

(a)   z = (x<6)
z = 0 1 0 1 1


(b)   z = (x<=y)
z = 0 0 0 1 1


(c)   z = (x==y)
z = 0 0 0 1 0


(d)   z = (x ~ =y)
z = 1 1 1 0 1

MATLAB CODE:


%Code start

clear all

x = [10 -2 6 5 -3];
y = [9 -3 2 5 -1];

z = x < 6
z = x <= y
z = x == y
z = x ~= y

%Code end

Code run result:

z =

0 1 0 1 1


z =

0 0 0 1 1


z =

0 0 0 1 0


z =

1 1 1 0 1

The results from hand and result from MATLAB are matching.

Hope this helps. Please let me know if there are any questions.
Cheers!

 Suppose that x =[10, -2, 6, 5 -3] and y = [9, -3 2, 5 -1] .find the results of the following operations by hand and use MATLAB to check your results z= (x less

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site