数据的维度不得超过 2 个!
我正在尝试在某些控制系统中进行开环分析。
首先,我分析了PT1,效果很好!
% Assigning the variables
Ksys = 0.8667;
T1 = 1.65;
% PT1 modeling
num = [0 Ksys];
den = [T1 1];
PT1 = tf(num, den);
% Step Response
t = 0:0.01:10;
y = 4.5 * step(PT1, t);
% Plotting
plot(t, y);
ylim([0, 6]);
但是当我分析高阶工厂时:
% Assigning the variables
Ksys = 0.8667;
Tc = 1.65;
Td = 0.25;
% PTn modeling
num = [0 Ksys];
den = [Tc 1];
PT1 = tf(num, den);
sh = pade(Td, 2);
PTn = PT1 * sh;
% Step Response
t = 0:0.01:10;
y = 4.5 * step(PTn, t);
% Plotting
plot(t, y);
ylim([0, 6]);
它给出以下错误:
??? Error using ==> plot
Data may not have more than 2 dimensions
Error in ==> TestProject at 25
plot(t, y);
我该如何解决这个问题?
I am trying to do open-loop analysis in some control system.
First, I analyze PT1, and it works fine!
% Assigning the variables
Ksys = 0.8667;
T1 = 1.65;
% PT1 modeling
num = [0 Ksys];
den = [T1 1];
PT1 = tf(num, den);
% Step Response
t = 0:0.01:10;
y = 4.5 * step(PT1, t);
% Plotting
plot(t, y);
ylim([0, 6]);
But when I analyze the higher order plant:
% Assigning the variables
Ksys = 0.8667;
Tc = 1.65;
Td = 0.25;
% PTn modeling
num = [0 Ksys];
den = [Tc 1];
PT1 = tf(num, den);
sh = pade(Td, 2);
PTn = PT1 * sh;
% Step Response
t = 0:0.01:10;
y = 4.5 * step(PTn, t);
% Plotting
plot(t, y);
ylim([0, 6]);
it gives the following error:
??? Error using ==> plot
Data may not have more than 2 dimensions
Error in ==> TestProject at 25
plot(t, y);
How can I solve this issue ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
plot
给出错误的原因是y
是一个 3D 数组,并且它需要一个 2D 矩阵。y
中的第二个维度是单一维度,出于各种目的,可以将其删除。使用函数squeeze
消除单一维度。请尝试以下操作:The reason
plot
gives you an error is becausey
is a 3D array and it expects a 2D matrix. The second dimension iny
is a singleton dimension and for all purposes, can be removed. Use the functionsqueeze
to get rid of the singleton dimension. Try the following:好吧,我找到了问题所在,它在 pade() 函数中。这是最终的代码:
Well, I figured out the probelm, it was in pade() function. Here is the final code: