Write a function which gets three numbers and return the summation and average o
ID: 1839479 • Letter: W
Question
Explanation / Answer
a)
function f1=avge(k1,k2,k3)
f1=(k1+k2+k3)./3;
end
b)
function f2 =grtr(k1,k2)
if (k1>k2)
f2=k1;
elseif (k1<k2)
f2=k2;
else
disp('equal');
end
end
c)
function f3 =sgn(k1,k2)
if (k1.*k2<0)
disp('opposite sign')
else
disp('same sign');
end
end
d)
function f4=zro(A)
n=size(A);
for k=1:n
if (A(k)<0)
A(k)=0;
end
end
end
e)
function f5=range(A,ini,fin)
f5=zeros(1,size(A));
n=size(A);
for k=1:n
if (ini<=A(k)<=fin)
f5(k)=1;
else
f5(k)=0;
end
end
end
f)
function f6 =count(A,d)
n=size(A);
f6=0;
for k=1:n
if (A(k)=d)
f6=f6+1;
end
end
end
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.