Experiment No. (5) M-files and Program Control Flow 1- (A) In the editor, write the following function Function [A,B,C] -myfunc(x.Z) % [A,B,C)=myfunc(x.Z) % Inputs: x is a constant, Z is an array %...

NoneExperiment No. (5)<br>M-files and Program Control Flow<br>1-<br>(A) In the editor, write the following function<br>Function [A,B,C] -myfunc(x.Z)<br>% [A,B,C)=myfunc(x.Z)<br>% Inputs: x is a constant, Z is an array<br>% Outputs: A=xtZ, B=x*Z and C=Z-x<br>A=x+2;<br>B=x*Z;<br>C=Z-x;<br>Temp A+B+C<br>end<br>• Save this file as the function name : myfunc.m.<br>• What is the output when the following commands are typed in the MATLAB command window?<br>> help myfunc<br>> A-rand(3,2);<br>> c=5;<br>> [HI, H2, H3]=myfunc(c,A)<br>> whos<br>(B) In the editor, type these lines in and save as myscript.m. It looks very similar to the function in (A)<br>clear<br>cle<br>A=rand(3,2);<br>c=5;<br>HI-c+A;<br>H2=c*A;<br>H3=A-c;<br>temp=H1+H2+H3<br>• To run the script, in the command window type myscript, then you can type whos to see what the new<br>variables are.<br>

Extracted text: Experiment No. (5) M-files and Program Control Flow 1- (A) In the editor, write the following function Function [A,B,C] -myfunc(x.Z) % [A,B,C)=myfunc(x.Z) % Inputs: x is a constant, Z is an array % Outputs: A=xtZ, B=x*Z and C=Z-x A=x+2; B=x*Z; C=Z-x; Temp A+B+C end • Save this file as the function name : myfunc.m. • What is the output when the following commands are typed in the MATLAB command window? > help myfunc > A-rand(3,2); > c=5; > [HI, H2, H3]=myfunc(c,A) > whos (B) In the editor, type these lines in and save as myscript.m. It looks very similar to the function in (A) clear cle A=rand(3,2); c=5; HI-c+A; H2=c*A; H3=A-c; temp=H1+H2+H3 • To run the script, in the command window type myscript, then you can type whos to see what the new variables are.

Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here