Matlab code pleas Write a function called \"P14\" P14 has two inputs \"vecName\"
ID: 2081157 • Letter: M
Question
Matlab code pleas
Write a function called "P14" P14 has two inputs
"vecName" : The name of an input vector.
and
"Oper": The specification of an operation.
P14 returns "Out14"
If Oper = 1, Out14 = vecName squared.
If Oper = 2, Out14 = 7* vecName +10.
If Oper = any other value, Out14 = 'Not a valid operation"
Write a function called "P14" P14 has two inputs
"vecName" : The name of an input vector.
and
"Oper": The specification of an operation.
P14 returns "Out14"
If Oper = 1, Out14 = vecName squared.
If Oper = 2, Out14 = 7* vecName +10.
If Oper = any other value, Out14 = 'Not a valid operation"v
Explanation / Answer
function [Out14]=P14(vecName,Oper)
if (Oper==1)
Out14=(vecName^2);
else if (Oper==2)
Out14=7*vecName+10;
else
error(Not a valid operation);
end