Data may not have more than 2 dimensions!
I am trying to do open-loop analysis in some control system.
First, I analyze PT1, and it works fine!
% Ass开发者_StackOverflow中文版igning 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 ?
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))
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]);
精彩评论