extra variables
Show older comments
I have an equation I am working with where I am altering the equation to solve for certain variables within the equation. I have used the syms function in the past and have never had a problem with it until today. I set up my equation and then ask it to solve for a certain variable. When it spits out the new equation Matlab has added two new variables to the mix. I've tried it 4 or 5 different ways and it continues to do the same thing. Does anyone know what is going on or why that is happening?
7 Comments
Sean de Wolski
on 12 Jul 2011
Show us the code!!
If we can't see what you're doing we can't help effectively.
Jason
on 12 Jul 2011
Sean de Wolski
on 12 Jul 2011
Do you have leftover variables from a previous run?
add:
clearvars
to the beginning of the file and see if it works.
Oleg Komarov
on 12 Jul 2011
Please edit your post formatting the code: http://www.mathworks.com/matlabcentral/answers/7885-tutorial-how-to-format-your-question
Jason
on 12 Jul 2011
Jason
on 12 Jul 2011
Jason
on 12 Jul 2011
Answers (2)
Walter Roberson
on 12 Jul 2011
0 votes
i or I represent the square root of negative 1. "i" is used at the MATLAB level, and "I" is used in symbolic forms.
2 Comments
Jason
on 12 Jul 2011
Walter Roberson
on 13 Jul 2011
Was it in the context of a RootOf() ? RootOf() introduces a dummy variable.
Kai Gehrs
on 13 Jul 2011
Hi Jason,
two things come to my mind which could be helpful.
First: defining P0 and afterwards using it in a character string, will not trigger any evaluation. A simple example is a = 2 and then using the input 'x^2 = a' as an equation for 'solve'. The value for 'a' will not be plugged into the equation. You would need to use something like ['x^2 = ' char(a)] to build the equation. The char command should trigger the evaluation.
Second: the solver uses new variables to parameterize solutions. E.g. something like k*pi as the solution of 'sin(x) = 0'. In the current version of the Symbolic Math Toolbox you will get a warning that the solutions are parameterized and it tells you something about which sets are used for that (e.g. the integers, the reals, certain intervals etc.).
As a workaround, you could try to use the 'evalin(symengine,cmd)' command, where cmd is a character string with a MuPAD command:
evalin(symengine,'solve(P0=(((1-g)/2)*(-cd*.6847*a*(((r*T)^.5)/V)*P1^k*t)+P1^k)^((2*g)/(1-g)),T)')
Hope this helps a bit,
-- Kai
Categories
Find more on Code Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!