MATLAB

Signal in MATLAB

signal in matlab

Sine Wave:

>>  x = 0:pi/100:2*pi;

>>  y = sin(x);

>>  plot(x,y)

OR

>>  y = sin(linspace(0,2*pi,10));

>>  stem(y)

Cosine Wave:

>>  x = 0:pi/100:2*pi;

>>  y = sin(x);

>>  plot(x,y)

OR

>>  y = cos(linspace(0,2*pi,10));

>>  stem(y)

Multiple Signals:

>>  x = 0:pi/100:2*pi;

>>  y = sin(x);

>>  y2 = sin(x-.25);

>>  y3 = sin(x-.5)

>>  plot(x,y,x,y2,x,y3)

Multiple Plots:

t = 0:pi/100:2*pi;

y1=sin(t);

y2=sin(t+pi/2);

subplot(2,2,1)

plot(t,y1)

subplot(2,2,2)

plot(t,y2);subplot(2,2,3)

plot(t,y1)

subplot(2,2,4)

plot(t,y2);

Square Wave Wave:

>>   t:0:100;

>>  y=square(2*pi*100*t/100,50);

>>   plot(t,y)

>>   stem(t,y)

Ramp Signal:

> >  t:0:20;

>>   plot(t,t);

>>   stem(t,t)

Exponential Signal:

>>   t=0:20;

>>  y2=exp(t);

>>   plot(t,y2)

>>   stem(t,y2)

Impulse Signal:

>>  t=-2:1:2;

>>  y=[zeros(1,2),ones(1,1),zeros(1,2)];

>>   plot(t,y);

>>   stem(t,y);

Step Signal:

>>   t=0.1:n-1;

>>  y1=ones(1,n-1);

>>  plot(t,y1)

>>   stem(t,y1)

Graph Functions:

  • plot linear plot
  • stem discrete plot
  • grid add grid lines
  • xlabel add X-axis label
  • ylabel add Y-axis label
  • title add graph title
  • subplot divide figure window
  • figure create new figure window
  • pause wait for user response

Leave a Reply

Your email address will not be published. Required fields are marked *