0% found this document useful (0 votes)
42 views7 pages

Generation of Continuous Time Sinusoidal Signal

The document describes how to generate various continuous and discrete time signals using MATLAB code. It includes sinusoidal signals, unit step signals, ramp signals, unit impulse signals, and complex exponential signals. It also provides code to perform convolution of discrete time signals.

Uploaded by

Madhav Khanal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views7 pages

Generation of Continuous Time Sinusoidal Signal

The document describes how to generate various continuous and discrete time signals using MATLAB code. It includes sinusoidal signals, unit step signals, ramp signals, unit impulse signals, and complex exponential signals. It also provides code to perform convolution of discrete time signals.

Uploaded by

Madhav Khanal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Generation of continuous time sinusoidal signal

Source Codes: t=-pi:0.01:pi x=sin(t) plot(t,x,'k') grid on title('sinusoidal signal') xlabel('time') ylabel('x(t)=sin(t)')

Generation of Discrete time sinusoidal signal


Source Codes: t=-pi:1:pi x=cos(t) stem(t,x,'k') grid on title('Discrete Time sinusoidal signal') xlabel('n') ylabel('x[n]=cos(t)')

Generation of continuous time unit step signal


Source Codes: hold on for(t=-10:0.01:10) if(t<0) plot(t,0,'k') else plot(t,1,'k') end end title('Unit Step') xlabel('t') ylabel('u(t)') grid on; hold off;

Generation of Discrete time unit step signal

Source Codes: hold on for(n=-10:1:10) if(n<0) stem(n,0,'k') else stem(n,1,'k') end end title('Unit Step') xlabel('n') ylabel('u[n]') grid on; hold off;

Generation of continuous ramp signal


Source Codes: hold on for(t=-10:0.01:10) if(t<0) plot(t,0,'k') else plot(t,t,'k') end end title('Ramp Signal') xlabel('t') ylabel('r(t)') grid on; hold off;

Generation of Discrete time unit impulse signal


Source Codes: hold on for(n=-10:1:10) if(n==0) stem(n,1,'k') else stem(n,0,'k') end end title('Unit Inpulse Signal') xlabel('n') ylabel('delta[n]') grid on; hold off;

Generation of continuous complex exponential signal


Source Codes: t=-10:0.01:10 c=2 w=4 r1=0.1 y=c*exp(r1*t).*(cos(w*t)+j*sin(w*t)) subplot(321) plot(t,real(y)) xlabel('t') ylabel('y(t)') title('Real part of complex exponential for r>0') subplot(322) plot(t,imag(y)) xlabel('t') ylabel('y(t)') title('Imag. part of complex exponential for r>0') r2=-0.1 y=c*exp(r2*t).*(cos(w*t)+j*sin(w*t)) subplot(323) plot(t,real(y)) xlabel('t') ylabel('y(t)') title('Real part of complex exponential for r<0') subplot(324) plot(t,imag(y)) xlabel('t') ylabel('y(t)') title('Imag. part of complex exponential for r<0') r3=0 y=c*exp(r3*t).*(cos(w*t)+j*sin(w*t)) subplot(325) plot(t,real(y)) xlabel('t') ylabel('y(t)') title('Real part of complex exponential for r=0') subplot(326) plot(t,imag(y)) xlabel('t') ylabel('y(t)') title('Imag. part of complex exponential for r=0')

Output

Convolution of x[n]={1,2,3} and h[n]={3,4,5}


Source Codes: x=[1,2,3]; h=[3,4,5]; y=conv(x,h); subplot(311) stem(x,'k') title('x[n]') grid on subplot(312) stem(h,'k') title('h[n]') grid on subplot(313) stem(y,'k') title('y[n][convoluted output]') grid on

Output

You might also like