4 Generate a block of MATLAB code that collects three values

4. Generate a block of MATLAB code that collects three values for an angle, theta. The code should then store these values in a column vector. Weta 5. Rewrite the following block of MATLAB code to use only one if statement. if y f z 10 w x y z end end Page 2 of 5

Solution

MATLAB CODE :-

4) First we need input three values of angle theta for this create a variable theta and then runninig a for loop. Now the three values are stores in variable theta.

function a = theta(theta)
clear
clc
disp(\'Enter Theta = \');
for i = 1:1:3
    theta(i) = input(\'\');
    i = i+1;
end
for i = 1:1:3
    if (i == 1)
        x = theta(i);
    elseif (i == 2)
            y = theta(i);
    elseif(i == 3)
        z = theta(i);
    end
end
a = [x;y;z]
end

5) Now theta stores in a which is column vector and using only if statement we get the required output.
@theta.m
if (x < y)
    if (z < 10)
        w = x*y*z;
        sprintf(\'w = %f \ \',w)
    end
end

 4. Generate a block of MATLAB code that collects three values for an angle, theta. The code should then store these values in a column vector. Weta 5. Rewrite

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site