How to substitute a vector symbolic variable with the values of a vector?
12 ビュー (過去 30 日間)
古いコメントを表示
x = sym('x',[1 2]).';
Q = [1 0;0 1]
f = x.'*Q*x;
xo = ones(2,1)
fo = (subs(f,{x(1),x(2)},{xo(1),xo(2)}))
x is a symbolic vector of dimension 50. I want to substitute 50 values in xo into each of x1,x2,....x50 in x.
Thanks a lot!
0 件のコメント
回答 (1 件)
madhan ravi
2018 年 9 月 28 日
編集済み: madhan ravi
2018 年 9 月 29 日
Your code works fine, you can substitute the same way using curly braces. What problem are you facing ?, everything seems to be fine in your code.
subs(f, x, xo) %edited after sir Walter’s comment.
4 件のコメント
Walter Roberson
2018 年 9 月 29 日
subs(f, x, xo)
In the case of vector of variables and vector of values the same size, corresponding substitute is done. The {} notation would be needed if at least one of the substitutions was not a scalar.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!