Ceate a vector of state space variable like A=[x(1), x(2), x(3),.....x(21)]

4 ビュー (過去 30 日間)
Ismaeel
Ismaeel 2015 年 3 月 15 日
編集済み: Ismaeel 2015 年 3 月 16 日
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 件のコメント
Andrew Newell
Andrew Newell 2015 年 3 月 16 日
But again, how do you get from there to solving
dx / dt = M(t)*x + b?
Ismaeel
Ismaeel 2015 年 3 月 16 日
編集済み: Ismaeel 2015 年 3 月 16 日
Look at this:
It is what I am working on
I did it already but without using matrices
Thanks for your contribution.

サインインしてコメントする。

採用された回答

John D'Errico
John D'Errico 2015 年 3 月 15 日
編集済み: John D'Errico 2015 年 3 月 15 日
The problem is, you apparently do not appreciate the basics of MATLAB.
One does not create a vector of (symbolic) variables to use in a tool like ode15s. ode15s takes a vector of NUMERIC starting values. It then returns a predicted solution based on the equations you pose, at a given set of times.
There are no symbolic variables that you need to create or define or allocate here. Really, it is best that you start reading the basic tutorials about variables and how to call functions, etc. These are fundamental concepts in MATLAB.
Regardless, as the help for sym indicates:
A = sym('A',[M N])
This creates M-by-N vectors or matrices of symbolic scalar variables.
  4 件のコメント
John D'Errico
John D'Errico 2015 年 3 月 15 日
Well, whatever your goal, why not use sym? From the help...
A = sym('A',[M N]) creates M-by-N vectors or matrices of symbolic scalar
variables...
Ismaeel
Ismaeel 2015 年 3 月 15 日
Thanks John. It creates A1 A2 A3 ...Amn
I need them to be like A(1) A(2) A(3)... A(mn)
Is there any function changes Amn to A(mn)?

サインインしてコメントする。

その他の回答 (1 件)

Giorgos Papakonstantinou
Giorgos Papakonstantinou 2015 年 3 月 15 日
Hallo Ismaeel. There is no need to use loop to do that. Check the colon usage of Matlab or the linspace command
For this you just simply do i.e.:
x = 1:21;
or
x = linspace(1, 10, 21);
  1 件のコメント
Ismaeel
Ismaeel 2015 年 3 月 15 日
Hi Giorgos
ok but I do not want to have values. I mean I need them to be variables without any values.
if you print x = 1:21; you will get a vector of values not variable.
I am looking for a function or loop so that I get a vector like
[x(1), x(2), x(3),.....x(21)]

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpecial Functions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by