Matlab Given x 7 6 1 2 0 1 4 3 2 0 what are the commands th

Matlab

Given x = [7, 6, 1, 2, 0, -1, 4, 3, -2, 0] what are the commands that will execute the following operations: Set the values of x that are less than the mean to zero. x(x

Solution

Mean function :

MATLAB function to find mean is mean(x).

Example program :

Set the values in x that are less than the mean to zero

x=[7 6 1 2 0 -1 4 3 -2 0];

n=length(x); // Here length is 10

for i=1:n if x(i)< mean(x) // loop runs from i value 1 to n and check x(i)< mean(x)

x(i)=0; // Here set the values in x that are less than the mean to zero

end

end

x

Observe the options :

Option 3 is correct choice.

Matlab Given x = [7, 6, 1, 2, 0, -1, 4, 3, -2, 0] what are the commands that will execute the following operations: Set the values of x that are less than the m

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site