Create a MATLAB script and a function script the MATLAB scri

Create a MATLAB script and a function script, the MATLAB script must ask user to enter any three complex numbers x, y and z five times, and display the values of x+2y, yz and argument of z/x. The values must be obtained using the function script that must have three input arguments and three output arguments.

Solution

% Function script within .m file is not supported for older version of Matlab. So making use of Anonymous function

for i = 0 : 5
x_real = input(\"Enter x-real value ::\\t\");
x_img = input(\"Enter x-imaginary value ::\\t\");
y_real = input(\"Enter y-real value ::\\t\");
y_img = input(\"Enter y-imaginary value ::\\t\");
z_real = input(\"Enter z-real value ::\\t\");
z_img = input(\"Enter z-imaginary value ::\\t\");
x = complex(x_real,x_img); % Convering into complex valu
y = complex(y_real,y_img);
z = complex(z_real,z_img);
function_script = @(x,y,z) ndgrid((x +2*y) ,(y*z),(arg(z/x))); % Anonymous function
[output1,output2, output3] = function_script(x,y,z); % calling the function
disp(output1);
disp(output2);
disp(output3);
end

Create a MATLAB script and a function script, the MATLAB script must ask user to enter any three complex numbers x, y and z five times, and display the values o

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site