Got Questions? Get Answers.
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:
fzero question?

Subject: fzero question?

From: Kyle McCool

Date: 4 Mar, 2009 00:05:04

Message: 1 of 4

Ok, I have asked a similar question before but this time I think this is a little simpler, I just don't know how to do it.
I have this equation:
e = [2*(1+((gamma-1)*1/2)*Me^2)/(gamma+1)]^((gamma+1)/(2*gamma-2))/Me

Gamma is known, (1.289) and I want to vary e from 0 to 100 (1 step intervals) and then solve for the corresponding Me so that I can plot Me as a function of "e". How do I even begin to do this?
I have tried fzero but it just won't work for me.

Subject: fzero question?

From: Matt Fig

Date: 4 Mar, 2009 00:28:17

Message: 2 of 4

Using fzero in a loop seems to work for me. The only problem I found is that when e = 0 or e = 1, fzero cannot find a solution. In the first case, there is no solution, in the second we have a tangent zero at 1. Other than that, fzero finds all roots.






X7*OLYpRKYUYiiS`K/$_i^XKwOYQpOWiiiZCiRKKVMKLO_^^ViKSZWYYcRM

Subject: fzero question?

From: Kyle McCool

Date: 4 Mar, 2009 00:36:01

Message: 3 of 4

"Matt Fig" <spamanon@yahoo.com> wrote in message <gokhv1$5dc$1@fred.mathworks.com>...
> Using fzero in a loop seems to work for me. The only problem I found is that when e = 0 or e = 1, fzero cannot find a solution. In the first case, there is no solution, in the second we have a tangent zero at 1. Other than that, fzero finds all roots.
>
>
>
>
>
>
> X7*OLYpRKYUYiiS`K/$_i^XKwOYQpOWiiiZCiRKKVMKLO_^^ViKSZWYYcRM

how did you write the loop? something like:
for i = 1:100
x0=10;
fzero(@fun, x0);
end
(I'm still very new to matlab)

Subject: fzero question?

From: Matt Fig

Date: 4 Mar, 2009 00:44:01

Message: 4 of 4

"Kyle McCool" <mycrapshootemail@gmail.com> wrote in message
>
> how did you write the loop? something like:
> for i = 1:100
> x0=10;
> fzero(@fun, x0);
> end
> (I'm still very new to matlab)

Yep, just like that:

gamma = 1.289;
rts = zeros(1,101);

for e = 0:100
T = @(Me) (2*(1+((gamma-1)*1/2)*Me.^2)/(gamma+1)) .^ ((gamma+1)/(2*gamma-2)) - (e*Me);
rts(e+1) = fzero(T,5); % Initial guess of 5.
end

rts(2) = 1; % From looking at the plot, rts(1) -> e = 0 has no solution.
plot(rts)






7ZSZh`^ZSgx]SgWfSq[kq`KWfaqUqT?aqaqSW WqfbTS[S_,qaY^xU_2baa

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