


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



a=[1.2 2.2 3.3 4.4 5.5 6.6] %input infr(a) %function calling function [in fr] = infr(x) %Function definition c=1; for (y=1:1:length(x)) fr(c)=rem(x(c),1); in(c)=x(c)-fr(c); c=c+1; end in %Output fr a=[1 2 3 4 5 6] %input isodd(a) %function calling function z=isodd(a) %FUNCTION DEFINITION for (x=1:1:length(a)) if (rem (a(x),2)==0) z=1; else z=0; end
z %output end a=[9 5 76 3 12 5 7] %%Input section mysum(sort(a)) %%calling function function z=mysum(a) %%function structure z=0; for (x=1:1:length(a)) z=z+a(x); end % a=[1 2 3 4] %%input section % b=[6 7 8 5] % % repel (a,b) %function calling function z=repel(a,b) %function defining c=1; d=zeros(1,sum(b)); %processing for (x=1:1:length(a)) for (y=1:1:b(x)) d(c)=a(x); c=c+1; end
if sum(w)== disp('Error!! sum of array w is zero'); elseif (length(x)~=length(w)) disp('Error !! arrays are not of same length'); else wam(x,w) function z=wam(x,w) sum1=0; sum=0; for (b=1:1:length(x)) sum=sum+(w(b)*x(b)); sum1=sum1+w(b); end z=sum=sum1; z