why am I getting the error "Incorrect number or types of inputs or outputs for function 'step."

210 次查看(过去 30 天)
my code is
clear all, close all
m1 = 10;
m2 = 350;
kw = 500000;
ks = 10000;
B = [ 1000 2000 3000 4000 ];
t = 0:0.01:2;
for i = 1:4
b = B(i);
F = [ 0 1 0 0; -( ks/m1 + kw/m1 ) -b/m1 ks/m1 b/m1; 0 0 0 1; ks/m2 b/m2 -ks/m2 -b/m2 ];
G = [ 0; kw/m1; 0; 0 ];
H = [ 1 0 0 0; 0 0 1 0 ];
J = 0;
y = step( F, G, H, J, 1, t );
subplot(2,2,i);
plot(t, y(:,1), ':', t, y(:,2), '-' );
legend('Wheel','Car');
ttl= sprintf('Response with b = %4.1f',b);
title(ttl);
end
and i got
"Incorrect number or types of inputs or outputs for function 'step'."
this message
  3 个评论
Mathieu NOE
Mathieu NOE 2023-9-22
this is ok for older matlab releases
if you use a recent matlab version, please create first the system sys and them call step(sys) as described in the doc :
FYI , in ttachment the "old" step function if you need it

请先登录,再进行评论。

回答(1 个)

Jon
Jon 2023-9-22
This runs for me in R2023b, what version are you running? If I look at the actual step.m file in my directory, which comes up as C:\Program Files\MATLAB\R2023a\toolbox\control\ctrlobsolete\step.m
I see that the calling arguments that you use will no longer be supported. Instead you must make a linear system and pass this to test. Perhaps on your version the call using A,B,C,D matrices is already no longer supported.
% Old help
%warning(['This calling syntax for ' mfilename ' will not be supported in the future.'])
%STEP Step response of continuous-time linear systems.
% STEP(A,B,C,D,IU) plots the time response of the linear system:
% .
% x = Ax + Bu
% y = Cx + Du
m1 = 10;
m2 = 350;
kw = 500000;
ks = 10000;
B = [ 1000 2000 3000 4000 ];
t = 0:0.01:2;
for i = 1:4
b = B(i);
F = [ 0 1 0 0; -( ks/m1 + kw/m1 ) -b/m1 ks/m1 b/m1; 0 0 0 1; ks/m2 b/m2 -ks/m2 -b/m2 ];
G = [ 0; kw/m1; 0; 0 ];
H = [ 1 0 0 0; 0 0 1 0 ];
J = 0;
y = step( F, G, H, J, 1, t );
subplot(2,2,i);
plot(t, y(:,1), ':', t, y(:,2), '-' );
legend('Wheel','Car');
ttl= sprintf('Response with b = %4.1f',b);
title(ttl);
end
In any case I would recommend calling using the current version of step, which is
figure % make new figure
m1 = 10;
m2 = 350;
kw = 500000;
ks = 10000;
B = [ 1000 2000 3000 4000 ];
t = 0:0.01:2;
for i = 1:4
b = B(i);
F = [ 0 1 0 0; -( ks/m1 + kw/m1 ) -b/m1 ks/m1 b/m1; 0 0 0 1; ks/m2 b/m2 -ks/m2 -b/m2 ];
G = [ 0; kw/m1; 0; 0 ];
H = [ 1 0 0 0; 0 0 1 0 ];
J = 0;
sys = ss(F,G,H,J);
y = step( sys,t );
subplot(2,2,i);
plot(t, y(:,1), ':', t, y(:,2), '-' );
legend('Wheel','Car');
ttl= sprintf('Response with b = %4.1f',b);
title(ttl);
end

类别

Help CenterFile Exchange 中查找有关 Plot Customization 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by