How to access individual solutions returned from vpasolve
3 views (last 30 days)
Show older comments
Hi
I'm using vpasolve for my homework to obtain numerical solutions. I switched to vpasolve because solve didn't seem to return the right solutions and it only returns one solution.
After vpasolve runs, I get an array of solutions. Since they're not all the right solution for my application (output voltage of CMOS inverter), I want to access only particular solutions.
How do I go about doing that? I've searched online and can't seem to find any syntax for indexing the solutions array.
Thanks!
0 Comments
Answers (1)
Walter Roberson
on 4 Oct 2019
If you returned the solution into individual variables then just index the variables in the regular way.
If you returned the solutions into a single variable and got a struct (call it SOL for the moment) then index SOL.variablename
Note that vpasolve only returns multiple solutions in the case that the equation is equivalent to a polynomial, and in that case solve always returns the correct solutions. solve would return them as exact solutions for quadratics, and sometimes for cubics, but for most cubics and quartics and all higher degree it would return placeholder forms written in terms of RootOf() or root(). You can vpa() or double() those if no free variables are in them.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!