-3

Lets say I have a matrix like this:

syms p;
K = [p^2+3 0; 2 5*p];
p_initial = 2;

Whats the proper/fastest way of getting K(p_initial), that is the resulting matrix if I insert 2 for p. Further, I want the resulting matrix to be of type double, not of symbolic type.

Thanks in advance

Doc
  • 345
  • 4
  • 17

1 Answers1

0

Use subs to substitute variables in symbolic expressions

subs(K,'p',p_initial)

ans =

[ 7,  0]
[ 2, 10]
Ander Biguri
  • 35,140
  • 11
  • 74
  • 120