extra variables

2 ビュー (過去 30 日間)
Jason
Jason 2011 年 7 月 12 日
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 件のコメント
Jason
Jason 2011 年 7 月 12 日
My apologies, there isnt much more editing I can do than this. I'll try the clear variables and try it again, I'll let you know what happens.
P0=(((1-g)/2)*(-cd*.6847*a*(((r*T)^.5)/V)*P1^k*t)+P1^k)^((2*g)/(1-g))
isen ='P0=(((1-g)/2)*(-cd*.6847*a*(((r*T)^.5)/V)*P1^k*t)+P1^k)^((2*g)/(1-g))'
solve(isen,'T')
ans =
(2.1330416924969127954324069056884*V^2*(1.0*P1^k - exp((3.1415926535897932384626433832795*l*(g - 1.0)*i)/g)/P0^((0.5*(g - 1.0))/g))^2)/(P1^(2.0*k)*a^2*cd^2*r*t^2*(0.5*g - 0.5)^2)
Jason
Jason 2011 年 7 月 12 日
Sean, I cleared the variables but I am still getting the same thing. I'll do it by hand but I just wanted to know if anyone had seen this before and what it might be doing. I forgot to include this:
syms P0 g cd a r T V P1 t k
These are my original variables.

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2011 年 7 月 12 日
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
Jason 2011 年 7 月 12 日
Okay, this may be a dumb question, why do both appear if they represent the same thing. The first few times I ran the equation I didn't use k as one of my variables but k popped up in the answer, does k stand for something similar?
Walter Roberson
Walter Roberson 2011 年 7 月 13 日
Was it in the context of a RootOf() ? RootOf() introduces a dummy variable.

サインインしてコメントする。


Kai Gehrs
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

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by