1- (A) In the editor, write the following function Function [A,B,C]-myfunc(x,Z) % [A,B,Cj=myfunc(x.Z) % Inputs: x is a constant, Z is an array % Outputs: A-x+Z, 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 myfune >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.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter2: Problem Solving Using C++using
Section2.1: Introduction To C++
Problem 1E: (Practice) State whether the following are valid function names and if so, whether they’re mnemonic...
icon
Related questions
Question
None
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.
Transcribed Image 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.
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Storage Devices
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr