step() giving a smooth curve for a discrete function

2 visualizzazioni (ultimi 30 giorni)
I am trying to work out the error between the a function and a discrete ZOH version of itself as shown in the image. When I use (R=step(Z,0:0.1:4); plot(x,R,'*') at the end it brings up a non ZOH held version of the TF. For some reason the output data (G(HS)) remains the same as H(s) yet the graph is ZOH.
%Method one
x=0:0.1:4;
hold on
H=tf(5,[1 5],'InputDelay',1); %http://au.mathworks.com/help/control/examples/specifying-time-delays.html
figure(1)
% step(H,0:0.1:4,'*');
% y=5*heaviside(x-1).*(1-exp(-5.*(x-1)));
%Method two
syms s c t z n
F=5*exp(-1*s)/(s+5)*(1/s); %with step responce
pretty(F)
assume(t > 0) %assume t>0 for the conversion
f=ilaplace(F,s,t); %inverse laplace
simplify(f)
figure(1)
o=ezplot(f,[0,4]); %plot for time domain from 0s to 4s
set(o,'Color',[1,0,0])
set(o,'LineStyle', '- -','LineWidth',2)
%%
% hold off
% figure(2)
% bode(H)
%%
Z=c2d(H,0.1,'zoh');
hold on
figure(1)
R=step(Z,0:0.1:4);
plot(x,R,'*')

Risposte (1)

Arkadiy Turevskiy
Arkadiy Turevskiy il 18 Apr 2017
It seems you are getting tripped up by the fact that the code below results in two identical lines
y1=step(H,x);
y2=step(c2d(H,0.1),x);
plot(x,y1);
hold;
plot(x,y2,'r')
but this code does not
close;
step(H,x);
hold;
step(c2d(H,0.1),x,'r');
There is no error here. As you noticed y1 and y2 are identical, as they should be, because your discretization step of 0.1 is the same step you use for defining x.
The reason why the first batch of code does not produce the same graph as second batch of code is that function plot always interpolates between data points. It is not the right function to use for plotting the step response of the discrete-time transfer function. For that, use the function stairs:
close;
plot(x,y1);
hold;
stairs(x,y2,'r')
Hope this helps.

Categorie

Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by