How to substitute a vector symbolic variable with the values of a vector?
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
madhan ravi
il 28 Set 2018
Modificato: madhan ravi
il 29 Set 2018
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 Commenti
Walter Roberson
il 29 Set 2018
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.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!