Subject: Solving Equations From: Chris Date: 13 Mar, 2009 17:23:02 Message: 1 of 5 Hi, I'm having trouble solving the following equation: M=E-e*sin(E); M and e have 5 values which should result in 5 values of E so that M(1), e(1) -> E(1) etc. I have tried solve, fzero and fsolve but either I exectud them incorrectly or they are the wrong function to solve this equation. The other consideration, is when this is implemented, it will be inside afor loop, generating 5 different values of M for each loop, so I can't realistically manually calculate them for the whole project. Cheers, Chris
 Subject: Solving Equations From: Matt Date: 13 Mar, 2009 17:37:01 Message: 2 of 5 "Chris " wrote in message ... > I have tried solve, fzero and fsolve but either I exectud them incorrectly or they are the wrong function to solve this equation. I would assume the former, since I am having no problem solving it with fzero. M=1,e=1;  f=@(E) E-e*sin(E)-M >> z=fzero(f,0) z =     1.9346 >> f(z) ans =  -2.2204e-016
 Subject: Solving Equations From: Chris Date: 13 Mar, 2009 19:01:01 Message: 3 of 5 That has now sorted it - many thanks! I'm now having trouble using the output of that. I'm sure its just me having a mental block! The output contains 9 rows of 100 x and y values (2 variables, x1 and y1) I want to plot 2 ellipses from 5 of these rows, defined by ps=[3,5:8]; In my mind, plot(x1(:,ps),y1(:,ps)) should do this, but for some reason its not! Cheers, Chris "Matt " wrote in message ... > "Chris " wrote in message ... > > > I have tried solve, fzero and fsolve but either I exectud them incorrectly or they are the wrong function to solve this equation. > > > I would assume the former, since I am having no problem solving it with fzero. > > M=1,e=1; > > f=@(E) E-e*sin(E)-M > > >> z=fzero(f,0) > > z = > > 1.9346 > > >> f(z) > > ans = > > -2.2204e-016
 Subject: Solving Equations From: Roger Stafford Date: 13 Mar, 2009 20:06:01 Message: 4 of 5 "Chris " wrote in message ... > Hi, I'm having trouble solving the following equation: > M=E-e*sin(E); > > M and e have 5 values which should result in 5 values of E so that M(1), e(1) -> E(1) etc. > > I have tried solve, fzero and fsolve but either I exectud them incorrectly or they are the wrong function to solve this equation. > > The other consideration, is when this is implemented, it will be inside afor loop, generating 5 different values of M for each loop, so I can't realistically manually calculate them for the whole project. > > Cheers, > Chris   The difficulties you might have with this equation depend very much on the magnitude of the e factor. Assuming E is measured in radians, if the absolute value of e is less than or equal to 1, there is always one and only one solution and fzero should be able to find it without much difficulty no matter what initial scalar estimate you give to it.   On the other hand if the absolute value of e is greater than 1, multiple roots become possible, and the larger the magnitude of e, the more roots there can be. With only a scalar initial estimate, this can make fzero appear inconsistent with results that depend on the inner workings of the fzero algorithm. Therefore, if you are working with e values of magnitude greater than 1, you need to devise some strategy for selecting an initial search range for E, as a two-element vector range estimate to hand to fzero, that includes the desired root and none other.   In other words, it is up to you to, in effect, select which root you want in this circumstance. The function fzero cannot read your mind; your loop has got to be made smart enough to perform this action. If it helps any, the successive roots of the equation cos(E)=1/e where the derivative of x-e*sin(x) changes sign (there are infinitely many) will always separate the possible roots of your equation, so the range estimate need only select the interval between the correct two successive roots to cos(E)=1/e.   As for 'solve', my matlab version is totally unable to find any analytic solution and I suspect that will remain true with newer versions. Roger Stafford
 Subject: Solving Equations From: Chris Date: 13 Mar, 2009 23:44:01 Message: 5 of 5 I had hoped to restrict my plots using this method to ellipses but it looks like that may not be possible. When calculating the hyperbolic sections, the equation changes to: e*sinh(F)-F-M I would use a simple if funtion to select which fzero to use based on the value of e and I guess that fzero would work for this new equation with e>1? I will find out when I work on it in the morning! Thanks for your help. Cheers, Chris "Roger Stafford" wrote in message ... > "Chris " wrote in message ... > > Hi, I'm having trouble solving the following equation: > > M=E-e*sin(E); > > > > M and e have 5 values which should result in 5 values of E so that M(1), e(1) -> E(1) etc. > > > > I have tried solve, fzero and fsolve but either I exectud them incorrectly or they are the wrong function to solve this equation. > > > > The other consideration, is when this is implemented, it will be inside afor loop, generating 5 different values of M for each loop, so I can't realistically manually calculate them for the whole project. > > > > Cheers, > > Chris > > The difficulties you might have with this equation depend very much on the magnitude of the e factor. Assuming E is measured in radians, if the absolute value of e is less than or equal to 1, there is always one and only one solution and fzero should be able to find it without much difficulty no matter what initial scalar estimate you give to it. > > On the other hand if the absolute value of e is greater than 1, multiple roots become possible, and the larger the magnitude of e, the more roots there can be. With only a scalar initial estimate, this can make fzero appear inconsistent with results that depend on the inner workings of the fzero algorithm. Therefore, if you are working with e values of magnitude greater than 1, you need to devise some strategy for selecting an initial search range for E, as a two-element vector range estimate to hand to fzero, that includes the desired root and none other. > > In other words, it is up to you to, in effect, select which root you want in this circumstance. The function fzero cannot read your mind; your loop has got to be made smart enough to perform this action. If it helps any, the successive roots of the equation cos(E)=1/e where the derivative of x-e*sin(x) changes sign (there are infinitely many) will always separate the possible roots of your equation, so the range estimate need only select the interval between the correct two successive roots to cos(E)=1/e. > > As for 'solve', my matlab version is totally unable to find any analytic solution and I suspect that will remain true with newer versions. > > Roger Stafford

Separated by commas
Ex.: root locus, bode

### 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.