time-dependence array in DAE Symbolic Math Toolbox
2 ビュー (過去 30 日間)
古いコメントを表示
Hi fellas,
My modeling consist of a box in which I divided into many sections in length. And the equation system that need to be solved is DAE with index 2.
For each and every section I have a physical property that depends only on time, and I have a model that describes this physical property.
So if I call my physical property as y. So my y will be written for every section and at a given time
y(i,t), i for the number of section, and t is the time.
So my problem is here, it seems that the symbolic math toolbox doesn't allow my variables to be written as y(i,t) in Syms (its gonna give me an error )
syms y(i,t)
and it has to be written as PHI(t). Thus forcing me to declare my variables as y_1(t), y_2(t), y_3(t),...y_n(t) if I have n sections. which is quite absurd like this one
syms rOM_1(t) rOM_2(t) rOM_3(t) rOM_4(t) rOM_5(t)...
rC_1(t) rC_2(t) rC_3(t) rC_4(t) rC_5(t)...
rI_1(t) rI_2(t) rI_3(t) rI_4(t) rI_5(t)...
rW_1(t) rW_2(t) rW_3(t) rW_4(t) rW_5(t)...
This is the case where I have 5 zones, I need like 20 or 30 zones...this is very repetitive..
Is there an easy way, so I can solve my DAE system with symbolic math toolbox so it can solve a time dependent matrix/array?
I'm so bad at explaining, excuse me, I tried my best. Just ask if you need more details.
Thanks.
0 件のコメント
回答 (1 件)
Walter Roberson
2015 年 6 月 7 日
Syms y(i,t)
should be
syms y(ii, t)
with lower-case "s" for "syms", and where you do not use "i" as a variable due to its use as the imaginary unit. This would also only be the case for y representing a function of two variables.
If you are looking for y representing an array then
y = sym('y', [N, M])
where N and M are the number of elements, such as
y = sym('y', [13, 42])
3 件のコメント
Marlon Saveri Silva
2018 年 3 月 31 日
Thanks, but... What about y as a t function?
How to declare y in order to have y = [y1(t), y2(t), ... yn(t)]?
Walter Roberson
2018 年 3 月 31 日
There is no syntax to create a vector of functions. The options are not good.
The following requires R2017b or later:
y = arrayfun(@(IDX) symfun(str2sym(sprintf('y%d(t)',IDX)),t),1:9, 'uniform', 0);
Note that you cannot have a vector of symfun, because indexing it would be ambiguous as to whether you were selecting one element of the vector or invoking the functions with an argument.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!