Continue to Site

# How to do MATLAB plotting in time for my examples?

Status
Not open for further replies.

#### james the cat

##### Newbie level 3
Can anyone please tell me what I need to do to enable me make MAPLAB plot the following outputs against time

i.e.

1. Here I am differentiating the system step response, to show that this give the impulse response, but how do I make MATLAB do “plot(t,x)” where t is 0 to 8ms and x is the step response differentiated.

clear
num=[0 0 2021004.003];
den=[1 1421.73674 1010502.002];
t=(0:0.00001:8e-3);
y=step(num,den,t);
x=diff;
x=x*100000;
plot(x)
xlabel(‘Time ( 10e-6 seconds)’), ylabel(‘Amplitude’),
title(‘System Step Response Differentiated’)
axis([0 800 –200 1000])

2. Here I am convolving the sin wave input y with the system impulse response, to find the system output, but how do I make MATLAB do “plot(t,z)” and “plot(t,z,t,y) i.e the system input and output together where t is 0 to 1s, y is the sine wave input and z is y convolved with the systems impulse response.

clear
num=[0 0 2021004.003];
den=[1 1421.73674 1010502.002];
t=(0:0.0001:1);
x=impulse(num,den,t);
y=((4/pi)*(sin(2*pi*30*t)));
z=conv(y,x);
plot(z)

I know that this can be done using the lsim command but am wanting to know how to do it as shown above.

Any one any ideas

Regards James

in your second case, i donno if u could plot the o/p vs time. you are dealing with disceret system where time info is lost.

you can plot the input and output on same plot using these

plot(input);
hold on
plot(output);

hope this helps ...

Status
Not open for further replies.