Learning Signal & System Using Matlab (Part_02)

Posted on at


Learning Signal & System Using Matlab(Part_02)

Script File
p = 2.9;
a(1) = 0.5;
for n = 1:99
a(n+1) = p*a(n)*(1-a(n));
end
a


In the Command Window


Q_01
a =

Columns 1 through 6
0.5000 0.7250 0.5782 0.7073 0.6004 0.6958
Columns 7 through 12
0.6139 0.6874 0.6232 0.6810 0.6300 0.6760
Columns 13 through 18
0.6352 0.6720 0.6392 0.6688 0.6424 0.6662
Columns 19 through 24
0.6449 0.6641 0.6469 0.6624 0.6485 0.6611
Columns 25 through 30
0.6498 0.6600 0.6508 0.6591 0.6516 0.6583
Columns 31 through 36
0.6523 0.6577 0.6529 0.6572 0.6533 0.6568
Columns 37 through 42
0.6537 0.6565 0.6539 0.6563 0.6542 0.6561
Columns 43 through 48
0.6544 0.6559 0.6545 0.6558 0.6546 0.6556
Columns 49 through 54
0.6547 0.6556 0.6548 0.6555 0.6549 0.6554
Columns 55 through 60
0.6549 0.6554 0.6550 0.6553 0.6550 0.6553
Columns 61 through 66
0.6551 0.6553 0.6551 0.6553 0.6551 0.6552
Columns 67 through 72
0.6551 0.6552 0.6551 0.6552 0.6551 0.6552
Columns 73 through 78
0.6551 0.6552 0.6551 0.6552 0.6552 0.6552
Columns 79 through 84
0.6552 0.6552 0.6552 0.6552 0.6552 0.6552
Columns 85 through 90
0.6552 0.6552 0.6552 0.6552 0.6552 0.6552
Columns 91 through 96
0.6552 0.6552 0.6552 0.6552 0.6552 0.6552
Columns 97 through 100
0.6552 0.6552 0.6552 0.655

a)

Function File

function y = Q_02(y0 , zeta , Wn , t , theta )
y = (y0*(exp(-1*zeta*Wn*t))*(sin(Wn*sqrt(1 - (zeta*zeta))*t+theta)))/(sqrt(1-zeta));
end


In the Command Window


Q_02(6,0.5,8,9,10)
ans = -1.9100e-16


b)


Function File

function y = Q_02(y0 , zeta , Wn , t , theta )
y = (y0*(exp(-1*zeta*Wn*t))*(sin(Wn*sqrt(1 (zeta*zeta))*t+theta)))/(sqrt(1-zeta));
end

Case_1


In the Command Window
i=1;
t=0.1;
while(t<10)
y1(i) = Q_02( 0.15 , 3/(2*sqrt(2)) , sqrt(2) , t , 0 );
i=i+1;
t= t + 0.1;
end
plot(y1)


Output

Case_2

In the Command Window

i=1;

t=0.1;

while(t<10)  

y2(i) = Q_02( 0.15 , 1/(2*sqrt(2)) , sqrt(2) , t , 0 );

i=i+1;      

t= t + 0.1;

end

plot(y2)

 

Output

Function File

function f = Q_03(Tc);

f = ((9/5)*Tc)+32;

end

In the Command Window

i = 1;

Tc = 0;

while(Tc<200)

Tf(i) = Q_03(Tc);

i = i+1;

Tc = Tc+10;

end

Tf

Output

Tf =

Columns 1 through 11

   32   50   68   86   104   122   140   158   176   194   212

Columns 12 through 20

   230   248   266   284   302   320   338   356   374

Function File

function y = Q_04(x)

y=exp(-x)*sin(8*x);

end

 

In the Command Window

 

i = 1;                                   

x = 0;

while(x<=(2*pi)) 

y(i) = Q_04(x);

i = i+1;

x = x+0.01;

end

plot(y)

 

Output

 

Function File

 

function exp1 = Q_05(x)

exp1 = 0 ;

   i = 1 ;

for n = 1:10;

   f = fact(n);

       a = x^(n)/f ;

       exp1 = exp1 + a ;

   i = i+1 ;

end

exp1 = 1 + exp1 ;

end

 

In the Command Window

 

Q_05(5)

ans =

146.3806

 

WRITER: naeem-annex



About the author

Ihtasham-Zahid

I am student of Electronics Engineering in International Islamic University Islamabad.

Subscribe 0
160