Error using "plot" : Data must be numeric, datetime, duration or an array convertible to double??
显示 更早的评论
Hi everyone. I wrote the following code but I get this error:
"error using plot: Data must be numeric, datetime, duration or an array convertible to double."
Kindly resolve this issue.
clear all
close all
clc
s=tf('s');
H = 1/(12*s+1);
Gp = 70/(50*s+1);
Gv=0.02/(4*s+1);
Gc = 0.0799;
Tsp = 1/s;
D = -0.01/s;
% Open loop transfer function:
GsHs = Gp*Gv*H;
sys = feedback(Gc*Gp*Gv,H);
stepinfo(sys)
t = 0:0.1:15;
[y,t] = step(sys);
e = 1-y; %this is E(s) due to Tsp(s) and D(s)
figure(1)
plot(t,e,'linewidth',2)
xlim([0,t(end)])
grid
title('error')
figure(2)
[y,t] = step(sys);
U = e.*Gc;
subplot(4,1,1);
plot(t,U,'linewidth',2);
grid
title('U(s)')
[y,t] = step(sys);
U0 = U.*Gv;
subplot(4,1,2);
step(U0);
grid
title('U0(s)')
[y,t] = step(sys);
T = (U0+D).*Gp;
subplot(4,1,3);
plot(t,T,'linewidth',2);
grid
title('T(s)')
[y,t] = step(sys);
Tm = T.*H;
subplot(4,1,4);
plot(t,Tm,'linewidth',2);
grid
title('Tm(s)')
2 个评论
Mathieu NOE
2020-12-31
hi
multiple errors because you attempt to plot a transfer function structure like here
Error in tmp (line 39)
plot(t,T,'linewidth',2);
what did you intend to plot from transfer function T ?
Muhammad Sanwal
2021-1-1
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

