Example # 1:-: Matlab Code
Example # 1:-: Matlab Code
EXAMPLE # 1:MATLAB CODE:inc=0.01; t=-10:inc:10; f=0.1; to=2; x=sin(2*pi*f*t); y=sin(2*pi*f*(t-to)); subplot(311); hold on; plot(t,x); plot(t,y,'r:'); grid subplot(312); plot(t,x); grid subplot(313); plot(t,y,'r:'); grid
RESPONSE:1
-1 -1 0 1
-8
-6
-4
-2
1 0
-1 -1 0 1
-8
-6
-4
-2
1 0
-1 -1 0
-8
-6
-4
-2
1 0
COMMENTS:In this matlab code we can see the shifting of two waves. Wave x=sin(2*pi*f*t). Is shifted by 2 unit time as y=sin(2*pi*f*(t-to)) shown in figure as doted line. Whish is shifted to times. EXAMPLE # 2:MATLAB CODE:inc=0.01; t=-10:inc:10; f=0.1; a=2; x=sin(2*pi*f*t); y=sin(2*pi*f*(a*8*t)); subplot(311); hold on; plot(t,x); plot(t,y,'r:');
-1 -10 1
-8
-6
-4
-2
10
-1 -10 1
-8
-6
-4
-2
10
-1 -10
-8
-6
-4
-2
10
COMMENTS:We check the shifted response of a sin wav x=sin(2*pi*f*t) if we change in time as a*8 is multiply with time in angle of sin. So we see that by multiplying with a*8 its amplitude is same but frequencyis changed.
inc=0.01; t=-10:inc:10; f=0.1; x=sin(2*pi*f*t); rx=fliplr(x); rt=fliplr(t); rt=-1*rt; l=length(x); subplot(311); hold on; plot(t(l/2:l),x(l/2:l)); plot(rt(1:l/2),rx(1:l/2),'r:'); grid title('example of time inversibale'); subplot(312); plot(t,x); grid ylabel('orignal signal'); subplot(313); plot(t,rx,'r:'); grid ylabel('time inversibale signal');
-8
-6
-4
-2
10
-1 -10 1
-8
-6
-4
-2
10
-1 -10
-8
-6
-4
-2
10
EXAMPLE 4:-
subplot(511); stem(time,signal,'r'); ylabel('signal'); subplot(512); stem(revtime,revsignal,'k'); ylabel('time reversal'); subplot(513); stem(time,odd); ylabel('odd'); subplot(515); stem(time,even+odd); ylabel('time reversal'); elseif(cod=='c') subplot(511); plot(time,signal,'r'); ylabel('signal'); subplot(512); plot(revtime,revsignal,'k'); ylabel('time reversal'); subplot(513); plot(time,odd); ylabel('odd'); subplot(515); plot(time,even+odd); ylabel('time reversal'); end
EXAMPLE 5:-
1 signal 0 -1 -1 0 1 0 -1 -1 0 1 0 -1 -1 0 -8 -6 -4 -2 0 2 4 6 8 10 -8 -6 -4 -2 0 2 4 6 8 10 -8 -6 -4 -2 0 2 4 6 8 10
tim e reversal
1 0 -1 -1 0 -8 -6 -4 -2 0 2 4 6 8 10
COMMENTS:It is the implementation file of example 4. In this we check whether the signal is even or odd and its time invariance.