MATLAB: How to copy struct elements into their original symbolic vectors

structsymbolicsystem of equations

I've got a script that solves an arbitrary number of equations for an arbitrary number of symbolic variables in the form of vectors, declared as follows:
n = 4;
h = sym('h', [ceil(n/2), 1]);
q = sym('q', [ceil(n/2)*floor(n/2), 1]);
And the equations are solved easily enough:
sol = solve(eqns);
Now I have the struct sol which contains the following:
h1: [1x1 sym]
h2: [1x1 sym]
q1: [1x1 sym]
q2: [1x1 sym]
q3: [1x1 sym]
q4: [1x1 sym]
Is there an easy and general way to copy these values back into the symbolic vector elements for any n?

Best Answer

subs(h, sol)
Related Question