Let us suppose that we run the following set of commands in Octave:
pkg load symbolic %loads the symbolic math package
syms x y %declare x and y symbols
f = x^2 - 2*x + 3;
V = [-5:0.25:5]';
V_x = subs(f, x, V)
At this point V_x
is a symbolic expression in Octave. Now, if this were to be MATLAB, one would run eval(V_x)
and everything would be converted to numbers. However, eval
does not seem to run in Octave as in MATLAB.
What should be done to convert the symbolic array into numbers?
double
has been overloaded for symbolic variables so you can use double
to explicitly convert the symbolic result to it's numeric representation
V_x_num = double(V_x);
This works in MATLAB as well as Octave.