Consider a userdefined function which takes 3 scalar input v

Consider a user-defined function, which takes 3 scalar input values. The function file returns 1 scalar output, which is calculated as the first value multiplied by the second value plus the third value. For example, entering 2, 3, and 4, will result in the value of 10 being returned to the command window (because 2 times 3 + 4 = 10). In the box below, write a MATLAB function file, named myfile .m, Using the following variable names: in1, in2, in3, and out. How would you type at the command prompt to get the response shown in the command window below? Note that this interaction corresponds to the numerical example described above. Submission: 1 function m-file, printout of your command window.

Solution

myfile.m :

function out = scalar(in1,in2,in3)

out=(in1*in2)+in3

In command prompt we type as

>> scalar(2,3,4)

 Consider a user-defined function, which takes 3 scalar input values. The function file returns 1 scalar output, which is calculated as the first value multipli

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site