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

1 Ansicht (letzte 30 Tage)
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 Kommentar
Christian
Christian am 18 Nov. 2014
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...

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu General Applications finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by