How to substitute a vector symbolic variable with the values of a vector?
    9 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
 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 comentarios
Respuestas (1)
  madhan ravi
      
      
 el 28 de Sept. de 2018
        
      Editada: madhan ravi
      
      
 el 29 de Sept. de 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 comentarios
  Walter Roberson
      
      
 el 29 de Sept. de 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.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


