step() giving a smooth curve for a discrete function
조회 수: 3 (최근 30일)
이전 댓글 표시

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,'*')
댓글 수: 0
답변 (1개)
Arkadiy Turevskiy
2017년 4월 18일
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!