extra variables
이전 댓글 표시
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
Sean de Wolski
2011년 7월 12일
Show us the code!!
If we can't see what you're doing we can't help effectively.
Jason
2011년 7월 12일
Sean de Wolski
2011년 7월 12일
Do you have leftover variables from a previous run?
add:
clearvars
to the beginning of the file and see if it works.
Oleg Komarov
2011년 7월 12일
Please edit your post formatting the code: http://www.mathworks.com/matlabcentral/answers/7885-tutorial-how-to-format-your-question
Jason
2011년 7월 12일
Jason
2011년 7월 12일
Jason
2011년 7월 12일
답변 (2개)
Walter Roberson
2011년 7월 12일
0 개 추천
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
Jason
2011년 7월 12일
Walter Roberson
2011년 7월 13일
Was it in the context of a RootOf() ? RootOf() introduces a dummy variable.
Kai Gehrs
2011년 7월 13일
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
카테고리
도움말 센터 및 File Exchange에서 Code Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!