Clear Filters
Clear Filters

Error message: Index exceeds the number of array elements. Index must not exceed 1. When I use trim function

9 views (last 30 days)
% 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);
Unrecognized function or variable 'model'.
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 Comments
Changyu
Changyu on 25 Oct 2023
After I run this. C:\Program Files\MATLAB\R2023a\toolbox\simulink\core\general\trim.p
Is .p means this file is a variable?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 25 Oct 2023
According to trim y0 must be immediately after u0
  3 Comments
Walter Roberson
Walter Roberson on 25 Oct 2023
[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);
Changyu
Changyu on 25 Oct 2023
Warning: Rank deficient, rank = 1, tol = 1.332268e-15.
> In qpsub
In nlconst
In simcnstr
In trim
In trim
Maximum number of function evaluations exceeded;
increase OPTIONS(14)
It doesn't work. I can't understand the error message.

Sign in to comment.

Categories

Find more on Modeling in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!