How to solve: Output 'mylength' (#194) has variable size but the upper bound is not specified; explicit upper bound must be provided.

조회 수: 1 (최근 30일)
Hi,
I am working on a simulink model using dynamic formula creation. In order to do so, I have the following subsystem, which is not working properly. I would like to divide a body into smaller parts of different length, mass and moment of inertia. So I thought about using matrizes with each element corresponding to a different part of the body.
function [mylength,I,massjoints] = initialise(length1A,length2A,width1A,N,mass)
mylength=zeros(N,1);
massjoints=zeros(N,1);
I=zeros(N,1);
split=round(N*0.68);
for i=1:split
mylength(i,1)=(length1A/(N*0.68));
massjoints(i,1)=((mass*0.68)/split);
end
for i=(split+1):N
mylength(i,1)=(length2A/(N*0.32));
massjoints(i,1)=((mass*0.32)/(N-split));
end
for i=1:N
I(i,1)=((massjoints(i,1)/12)*((mylength(i,1)^2)+width1A^2));
end
<<< The input variables are all integer numbers.
I got the error message #87 at first, stating that the matrix "mylength" is of variable-size but otherwise specified. Then I ticked the variable-size button in model explorer. I gave different values for the upper bound (integer numbers, matrizes and the input "N") none of these worked and gave me the error in the title.
Do you know how to work around that problem?
Many Thanks, Christian
  댓글 수: 1
Christian
Christian 2014년 11월 18일
I tried to work around the problem, as I don't see the problem in the syntax. I get the responds: Data 'mylength' (#192) is inferred as a variable size matrix, while its specified type is something else. I feel like this is the real problem. As I try to dynamically create vectors here. Maybe someone has an idea...

댓글을 달려면 로그인하십시오.

답변 (1개)

Shreeya
Shreeya 2024년 10월 8일
Hello
If the size of a variable can change during model simulation, setting the sizes in the Data Editor for the MATLAB Function Block is required. Refer to the below documentation for more information on this:
Also, if the variable size does not change during simulation, it's "tunable" property should be set to off.
Refer to the below MATLAB answers link to understand more about both the scenarios:

카테고리

Help CenterFile Exchange에서 General Applications에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by