MATLAB Function Definitions and Calls, Exercises of Signals and Systems Theory

Various matlab function definitions and calls, including 'infr', 'isodd', 'mysum', 'repel', and 'sss'. Each function performs specific operations on input arrays, such as finding remainders, checking oddness, calculating sums, and checking triangle conditions.

Typology: Exercises

2011/2012

Uploaded on 07/14/2012

kapor
kapor 🇮🇳

4

(1)

37 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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
docsity.com
pf3
pf4

Partial preview of the text

Download MATLAB Function Definitions and Calls and more Exercises Signals and Systems Theory in PDF only on Docsity!

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