Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
transcendental equation solution question

Subject: transcendental equation solution question

From: Kyle

Date: 13 Feb, 2009 00:48:02

Message: 1 of 6

Hi, I have this equation:
e = [2*(1+((Gamma-1)*1/2)*Me^2)/(Gamma+1)]^((Gamma+1)/(2*Gamma-2))/Me

Gamma is a matrix with 7 elements in it and both "e" and "Me" are unknowns. I want to vary "e" from 1 to 100 and solve for "Me" one Gamma value at a time. I have tried to create a function handle and use the "fzero" function but I can't seem to get it to work at all. I'm just looking for any pointers. Thanks in advance!

Subject: transcendental equation solution question

From: Roger Stafford

Date: 13 Feb, 2009 01:12:01

Message: 2 of 6

"Kyle " <mycrapshootemail@gmail.com> wrote in message <gn2g02$eb4$1@fred.mathworks.com>...
> Hi, I have this equation:
> e = [2*(1+((Gamma-1)*1/2)*Me^2)/(Gamma+1)]^((Gamma+1)/(2*Gamma-2))/Me
>
> Gamma is a matrix with 7 elements in it and both "e" and "Me" are unknowns. I want to vary "e" from 1 to 100 and solve for "Me" one Gamma value at a time. I have tried to create a function handle and use the "fzero" function but I can't seem to get it to work at all. I'm just looking for any pointers. Thanks in advance!

  What difficulties have you had with 'fzero'? It should be pointed out that with only one equation to satisfy, you cannot in general solve for both e and Me as unknowns. You must assign one of them values to try, as you seem to have done. For each value of e and gamma you assign, 'fzero' ought to be able to find the corresponding value or values for Me if any exist. Of course it may depend on being able to give initial estimates which are "within the right ball park". Perhaps that is your difficulty?

Roger Stafford

Subject: transcendental equation solution question

From: matlabsky@gmail.com

Date: 13 Feb, 2009 05:42:01

Message: 3 of 6

use the function "fsolve()" can quitely be easy to solve your
problem,just see next Matlab code


 %by matlabsky
%see also http://www.matlabsky.com
%2009.2.13

function matlabsky
%here just suppose Gamma
Gamma=rand(7,1)*10;
objfun=@(Me,e)(2*(1+((Gamma-1)*1/2).*Me.^2)./(Gamma+1)).^((Gamma+1)./
(2*Gamma-2))./Me-e
result=zeros(100,7,2);
for ii=1:100
    [x,fval]=fsolve(@(Me)objfun(Me,ii),rand(7,1)*10);
    result(ii,:,1)=x;
    result(ii,:,2)=fval;
end
%the format of result
%the (ii,jj,:) is the results where e=ii,gamma=Gamma(jj)

%something i want to say
%fsolve() must have a initialize value which is very important
%the above i just give a random value

Subject: transcendental equation solution question

From: 风雪夜归人

Date: 13 Feb, 2009 05:58:01

Message: 4 of 6

%by matlabsky
%see also http://www.matlabsky.cn\
%2009.2.13

function matlabsky
%here just suppose Gamma
Gamma=rand(7,1)*10;
objfun=@(Me,e)(2*(1+((Gamma-1)*1/2).*Me.^2)./(Gamma+1)).^((Gamma+1)./
(2*Gamma-2))./Me-e
result=zeros(100,7,2);
for ii=1:100
    [x,fval]=fsolve(@(Me)objfun(Me,ii),rand(7,1)*10);
    result(ii,:,1)=x;
    result(ii,:,2)=fval;
end
%the format of result
%the (ii,jj,:) is the results where e=ii,gamma=Gamma(jj)

%something i want to say
%fsolve() must have a initialize value which is very important
%the above i just give a random value

Subject: transcendental equation solution question

From: Walter Roberson

Date: 14 Feb, 2009 18:29:07

Message: 5 of 6

Kyle wrote:
> Hi, I have this equation:
> e = [2*(1+((Gamma-1)*1/2)*Me^2)/(Gamma+1)]^((Gamma+1)/(2*Gamma-2))/Me
>
> Gamma is a matrix with 7 elements in it and both "e" and "Me" are unknowns.
> I want to vary "e" from 1 to 100 and solve for "Me" one Gamma
value at a time.

I am confused about that solving "one Gamma value at a time". If
Gamma is a vector, then the subexpression ending with Me^2 is a
vector, and subexpression (Gamma+1) is a vector of the same size,
so you would be asking to perform an mrdivide between two vectors.
Whether that is going to produce a 1 x 1 vector or a 7 x 7 vector
is going to depend upon whether Gamma is 1 x 7 or 7 x 1.

You then take that result and raise it to a power. The power you
raise it to is going to have the same size as the other part,
either 1 x 1 or 7 x 7, because the exponent has an mrdivide
as well.

Are you sure you know what you are doing??

Or for the purpose of this problem, should we assume that you have
7 different Gamma values that you want to solve for and that we
should make whatever adjustments we need to the expression in order
to run it that way.. that vectorization would be nice but not
important?

If the latter is the case, then there is unfortunately no analytic
solution to the expression, not unless Gamma is restricted the
the particular values 3, 5/3, 1/3, or possibly a very small number
of other values (a 0 fits in there somewhere.)

Subject: transcendental equation solution question

From: Kyle

Date: 14 Feb, 2009 22:14:02

Message: 6 of 6


Walter--
When I said that I want to solve for one gamma value at a time, I meant that i want to call up the first value in the gamma matrix and then vary "e" from 1 to 100 and solve for "Me" After that runs, I want to call up the 2nd gamma value and do the same thing. So really, I'm holding the gamma value constant for the calculation but I just have to do the same calculation for 7 different gasses. Does this make sense to you now?

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us