数据的维度不得超过 2 个!

发布于 2024-11-10 00:40:16 字数 773 浏览 3 评论 0原文

我正在尝试在某些控制系统中进行开环分析。

首先,我分析了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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

街角卖回忆 2024-11-17 00:40:16

plot 给出错误的原因是 y 是一个 3D 数组,并且它需要一个 2D 矩阵。 y 中的第二个维度是单一维度,出于各种目的,可以将其删除。使用函数 squeeze 消除单一维度。请尝试以下操作:

plot(t',squeeze(y))

The reason plot gives you an error is because y is a 3D array and it expects a 2D matrix. The second dimension in y is a singleton dimension and for all purposes, can be removed. Use the function squeeze to get rid of the singleton dimension. Try the following:

plot(t',squeeze(y))
绝不放开 2024-11-17 00:40:16

好吧,我找到了问题所在,它在 pade() 函数中。这是最终的代码:

% Assigning the variables
Ksys = 0.8667;
Tc = 1.65;
Td = 0.25;

% PTn modeling
num = [0 Ksys];
den = [Tc 1];
PT1 = tf(num, den);
[nums, dens] = pade(Td, 2);
sh = tf(nums, dens);
PTn = PT1 * sh;

% Step Response
t = 0:0.01:10;
y = 4.5 * step(PTn, t);

% Plotting
plot(t, y);
ylim([0, 6]);

Well, I figured out the probelm, it was in pade() function. Here is the final code:

% Assigning the variables
Ksys = 0.8667;
Tc = 1.65;
Td = 0.25;

% PTn modeling
num = [0 Ksys];
den = [Tc 1];
PT1 = tf(num, den);
[nums, dens] = pade(Td, 2);
sh = tf(nums, dens);
PTn = PT1 * sh;

% Step Response
t = 0:0.01:10;
y = 4.5 * step(PTn, t);

% Plotting
plot(t, y);
ylim([0, 6]);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文