How to plot state variable responses?
2 ビュー (過去 30 日間)
古いコメントを表示
I am attempting to plot the four plots of the state variable step response. I keep getting the following error:
Error using DynamicSystem/step (line 95)
For models with unspecified sample time, time is counted in samples and the time increment must be 1 (one sample).
How can I keep the time at 0.01 sample rate? It will work just fine with t=[0:1:5]
Here is my code:
%Assigning Variables
m1=20;
m2=375;
kw=100000;
ks=10000;
b=2000;
A=[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];
B=[0;
kw/m1;
0;
0];
C=[1 0 0 0;
0 0 1 0];
D=0;
sys = ss(A,B,C,D,[], 'StateName', {'A' 'B' 'C' 'D'}); % note B is used !
t = [0:1:5]';
[y, t, x] = step(sys,t);
for i=1:4
subplot(4,1,i);
plot(t, x(:,i)); % look at how I indexed into x
end
0 件のコメント
回答 (1 件)
Prathamesh
2025 年 4 月 29 日
I understand that while plotting plots of the state variable step response the following error “Error using DynamicSystem/step” is getting displayed.
This issue arises because the system is currently defined as continuous-time, but the time vector provided is causing MATLAB to interpret it as a discrete-time system.
In continuous-time systems, MATLAB allows for any time increment (such as 0.01 seconds). However, for discrete-time systems, the time values must increase by exactly 1 at each step. If the time vector increments do not match the system type, MATLAB will display this error.
To resolve this, please ensure that your system is defined as continuous time by omitting the sample time parameter in the “ss” command. Additionally, use a time vector in seconds with your preferred time increment. This should allow you to use the “step” function without encountering any errors.
For additional information, refer the the following MathWorks Documentation on ” Continuous-Time System Models“:
Hope this helps.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Deep Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!