Error message: Index exceeds the number of array elements. Index must not exceed 1. When I use trim function
9 次查看(过去 30 天)
显示 更早的评论
% Define the trim condition
Y0 = 2500; % RPM
X0 = [2500; 0; 0; 0]; % Initial guess for the state vector
U0 = 0; % Input value for trimming
% Perform the trimming
[X0, U0] = trim(model,X0,U0,[],[],Y0);
The above is my code. Unfortunately, I can't provide the model. The Simulink Model have one input and Three output. But two of three output connects to the Terminator Block.
3 个评论
回答(1 个)
Walter Roberson
2023-10-25
3 个评论
Walter Roberson
2023-10-25
[x,u,y,dx] = trim('sys',x0,u0,y0,ix,iu,iy) finds the trim point closest to x0, u0, y0 that satisfies a specified set of state, input, and/or output conditions. The integer vectors ix, iu, and iy select the values in x0, u0, and y0 that must be satisfied.
You are passing Y0 in the iy position, and Y0 = 2500 in your code. That tells trim() that the 2500'th y0 value must be satisfied. But you only have one y0 value, which is the scalar Y0.
The iy is an index not a value .
You should probably just be using
[X0, U0] = trim(model,X0,U0,Y0);
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!