Question

I am trying solve the differential equation enter image description here by first putting it in normal, which, if I did it correctly, should be dx/dt = a8 1/3 x - 1/3 b8, where a8 is the second derivative, and b8 is the third derivative. Here is a portion of my code:

matlabFunction( [a8 +x8/3 - b8/3; a8; b8],'vars',{t,[b8;a8;x8]},'file','DE_11')

And here are the errors I get:

Error using sym/cat>checkDimensions (line 75)
CAT arguments dimensions are not consistent.

Error in sym/cat>catMany (line 38)
[resz, ranges] = checkDimensions(sz,dim);

Error in sym/cat (line 27)
    ySym = catMany(dim, strs);

Error in sym/vertcat (line 19)
    ySym = cat(1,args{:});

I honestly do not know what these messages are hinting at. I was hoping someone could help me decipher these error messages, and show me where I went wrong. My intention is, after these issues have been resolved, to use ode45 to solve the differential equation.

Thank you, and I apologize for my ignorance.

EDIT: Okay, after having aimlessly tried various things, I was able to get it to "work." Here is what I changed it to:

matlabFunction([b8;a8;a8 - b8/3 - x8/3], 'vars',{t8,x8,[b8,a8]},'file','DE_11')

However, I am not really certain as to why that worked, or if its even the correct input. Could someone perhaps show me why it worked? I understand that this [b8;a8;a8 - b8/3 - x8/3] represents a column vector containing my unknown functions, but I do not exactly understand this part {t8,x8,[b8,a8]}. I know that we are defining variables, but why do we use curly brackets, and why are some enclosed in square brackets, and others are not?

Était-ce utile?

La solution

the error is caused by

[a8 +x8/3 - b8/3; a8; b8]

as this attempts to create a matrix with inconsistent dimensions as the first space separates column entries in the first row. using no spaces or spaces either side of the operators will solve this...

[a8 + x8/3 - b8/3; a8; b8] or [a8+x8/3-b8/3; a8; b8]

should work as intended.

see http://www.mathworks.co.uk/help/matlab/matlab_prog/symbol-reference.html#bsgigzp-52

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top