From here, I’m trying to solve a symbolic system of equations like this
syms x y z;
[x, y, z] = solve('z = 4*x', 'x = y', 'z = x^2 + y^2')
x =
0
2
y =
0
2
z =
0
8
except that my equations are generated at different points in the m-file and with random coefficients. My question is how can I accomplish the following…
// Generate the first equation.
n = *random number generated here*;
E1 = (z == n*x + 2*n); // <--- How to save this symbolic equation to use in "solve(...)" later?
// Other work, generate other eqs.
...
// Solve system of eqs.
[x, y, z] = solve( E1 , E2, E3) // What/How to call/use the previously saved symbolic equations.
Thanks for the help!
EDIT
Updated to better explain objective.
Use
sprintfif you want to keep the randomly generated value ofnfor later use withsolve:You can play with the parameters on
%fto see how much precision you want to include.