Simulating linear model, can't understand error
1 次查看(过去 30 天)
显示 更早的评论
I have a linear system called "ss" identified using "velocity", "position", and "time_sec_" vectors imported from a CSV file.
Used time interval of 0.02, delay of 0.4, included disturbance.
The 3rd order system looks like this:
>> [A,B,C,D,K,x0,dA,dB,dC,dD,dx0] = idssdata(ss)
A =
-0.2101 -3.0985 -0.8638
2.5007 -4.9519 -11.9558
0.1966 0.4627 8.4746
B =
0.0056
-0.0048
-0.0562
C =
31.8116 -0.8537 0.0245
D =
0
K =
1.3349
-32.7004
40.9704
x0 =
-0.0165
-0.0724
0.0023
dA =
1.0e+14 *
1.2124 0.1556 0.1185
2.6893 1.5376 1.1212
2.1587 1.5017 1.2671
dB =
1.0e+11 *
0.2318
4.1463
5.7636
dC =
1.0e+14 *
1.0754 0.0817 0.0737
dD =
0
dx0 =
1.0e+14 *
0.0877
1.6986
2.8014
I want to simulate the system. It's SISO (velocity -> position) but because it's third order I have to duplicate the velocity three times, one for each system state variable.
U = velocity * ones(1, 3)
Here is what I am calling lsim with:
>> size(U)
ans =
2415 3
>> size(time_sec_)
ans =
2415 1
I attempt to simulate the system:
lsim(ss, U, time_sec_)
Matlab returns the following error:
Error using DynamicSystem/lsim
When simulating the response to a specific input signal, the input
data U must be a matrix with as many rows as samples in the time
vector T, and as many columns as input channels.
This error message doesn't make sense because:
- U has as many rows as time samples in time_sec_ vector
- U has as many columns as rows in "B" matrix in the model (third order model, B has 3 rows)
- time_sec_ vector has one row for each time sample
- Time samples are absolute values increasing in time, in seconds
0 个评论
采纳的回答
Paul
2024-4-16
编辑:Paul
2024-4-17
Hi Valeriy,
Because the B matrix has one column, the input to the system is a scalar. Hence the U input to lsim should have one column and as many rows as time samples. Each entry in U is the scalar input to the the system at the corresponding time sample in time_sec_
Also, I suggest not using ss as a variable name. Doing so overrides the same-named functions in a couple of different toolboxes.
which ss -all
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Response Computation and Visualization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!