Ceate a vector of state space variable like A=[x(1), x(2), x(3),.....x(21)]
Show older comments
Hi...
How can I create a vector of state space variables by a loop to get
[x(1), x(2), x(3),.....x(21)]
I need this vector to use it in ODE15 as state space variables vector multiplied by other matrices forming DAEs.
Thanks
12 Comments
Andrew Newell
on 15 Mar 2015
What vector do you want to create?
Andrew Newell
on 15 Mar 2015
Edited: Andrew Newell
on 15 Mar 2015
ismaeel, I think you're barking up the wrong tree. As John D'Errico points out below, the ODE suite accept numeric objects and function handles, not symbolic objects.
As far as I can tell from your description of this problem, what you're really after is a function M = MASS(t,y) for the mass matrix, where t is time and y is the state vector. If I'm wrong, you'll need to add more detail about what you're trying to do and how you're trying to do it.
Jan
on 15 Mar 2015
When you have expressions like x(1) to x(21), the "x" is a vector already. Therefore I still do not understand what you want to achieve. When Matlab does not match your needs directly, try to use Matlab as it is designed to solve your problem.
Ismaeel
on 15 Mar 2015
Edited: Andrew Newell
on 15 Mar 2015
Andrew Newell
on 15 Mar 2015
So do you want to turn the function output into something like this?
Out = M * x;
And if so, are you wondering how to formulate it as a matrix equation, import M into the function, or both?
Ismaeel
on 15 Mar 2015
Ismaeel
on 16 Mar 2015
Andrew Newell
on 16 Mar 2015
Edited: Andrew Newell
on 16 Mar 2015
That gives you
x =
x(sqrt(-1))
x(2)
x(3)
x(4)
x(5)
x(6)
x(7)
x(8)
x(9)
x(10)
I don't see how that helps - even if the first entry were x(1).
Andrew Newell
on 16 Mar 2015
But again, how do you get from there to solving
dx / dt = M(t)*x + b?
Accepted Answer
More Answers (1)
Categories
Find more on Number Theory in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!