step function gives Error using step Not enough input arguments.

12 ビュー (過去 30 日間)
Dexter
Dexter 2023 年 2 月 1 日
回答済み: Fangjun Jiang 2023 年 2 月 1 日
I want to make a simulation of a plant, I wrote this code but it throws this error: Error using step Not enough input arguments.
% Define the transfer function of the plant
num_p = [13];
den_p = [1 -1/13];
p = tf(num_p, den_p);
% Define the transfer function of the controller
num_c = [40/13];
den_c = [1 (1/13 + 0.2) (0.2/13)];
c = tf(num_c, den_c);
% Find the transfer function of the closed-loop system
cl = feedback(p, c);
amplitudes = 20:5:60;
t = 0:0.01:100;
figure;
for i = 1:length(amplitudes)
amplitude = amplitudes(i);
input_signal = amplitude * step(t);
[y, t_out] = lsim(cl, input_signal, t);
plot(t_out, y);
hold on;
end
xlabel('Time (s)');
ylabel('Output (y)');
title('Response');
legend(num2str(amplitudes'));

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2023 年 2 月 1 日
Not the correct way to use step(). It is used to get the step response of a system, not to get the step input signal.
You can use step() in replace of lsim(). Look at the examples in "doc step".

カテゴリ

Help Center および File ExchangeClassical Control Design についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by