From: Rick on
I have a function

v2 = createV_k(2,gamma);

Which creates a symbolic expression as shown below:-

v2 =

(1/u1^gamma)^(1/gamma + 1)/(1/u1^gamma + 1/u2^gamma - 1)^(1/gamma + 1)

The equation above has the following symbolic variables

>> symvar(v2_eqn)

ans =

[ gamma, u1, u2]

What I would like to do is that I want to re-arrange the formula above and solve for u2. However, what’s the best way to do this? Basically I’d like to have u2 on the right hand-side and have v2 on the left hand side with u1 & gamma.

I can’t use solve(v2,u2) as it automatically equates v2 to zero as per the documentation. The only other way I can think of is to do it in the form

solve(‘v2=(1/u1^gamma)^(1/gamma + 1)/(1/u1^gamma + 1/u2^gamma - 1)^(1/gamma + 1)’,u2)

The above is a little unwieldy and I’m unsure as to how I can convert the output of the createV_k function into a string and spend the ‘v2=’ at the front. I hope someone can help me with this or recommend a simpler solution.

I’m just starting off to use the symbolic toolbox function thus any help or hints would be great!