Assign values to variables in a loop
古いコメントを表示
syms a [1 n];
...
for i=1:n-1
...
a(i+1) = rhs(isolate(eqn,a(i+1)));
a(i+1);
end
I'm trying to assign the expression rhs(isolate(eqn,a2)) to the symbolic variable a2, rhs(isolate(eqn,a3)) to a3, up to an.
I have absolutely no idea how to do this. a(i + 1) assigns the value to the array a, rather than the variable in a(i + 1). If I change i=1:n-1 to i=2:n and put ai, it only assumes ai to be some other variable, rather than replacing i with its value and referring to a2 or a3 or whatever.
What I'd like is for a(i + 1) to refer to the actual variable at that index location, rather than referring to the index location itself. Thing is, it actually does get a2 and a3 etc. in the isolate equation, but it doesn't on the left side???
2 件のコメント
madhan ravi
2019 年 4 月 27 日
編集済み: madhan ravi
2019 年 4 月 27 日
What do you mean by "Assign values to variables in a loop" ?
What is your question?
What are you trying to do?
What are the inputs?
What is the desired output?
Where is the example of your illustration?
Is this a homework?
Lucian Williams
2019 年 4 月 27 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Common Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!