On 28 Feb., 15:44, "John D'Errico" <woodch...@rochester.rr.com> wrote:
> "Michael Boyd" wrote in message <jiil4l$7b...@newscl01ah.mathworks.com>...
> > "John D'Errico" <woodch...@rochester.rr.com> wrote in message <jiikjq$5n...@newscl01ah.mathworks.com>...
> > > "Michael Boyd" wrote in message <jiiegm$gs...@newscl01ah.mathworks.com>...
> > > > Hi guys,
>
> > > > I am trying to find the value of variable, 'crank', that satisfies 2 equations.
>
> > > > Here is the script.
>
> > > > clc
> > > > clear all
>
> > > > a=13.5;
> > > > l=48;
> > > > crank=0:pi/900:2*pi;
> > > > phase=30;
>
> > > > positionEX=a*cos(crank)+(l^2a^2*sin(crank).^2).^0.5;
> > > > positionIN=a*cos(crankphase)+(l^2a^2*sin(crankphase).^2).^0.5;
>
> > > > I am trying to find the first 'crank' value when 'positionEX' is greater or equal to 59.75 AND when 'positionIN' is more than 58.75.
>
> > > > I am unsure how you would do this.
>
> > > Because you are thinking of it in the wrong way. You are
> > > NOT solving two equations. You wish to minimize crank,
> > > subject to a set of nonlinear constraints on it.
>
> > > And, yes, you will want to set up a function for at least
> > > the nonlinear constraints. The objective function for
> > > fmincon can be done as an anonymous function.
>
> > > If you prefer not to do it that way (or don't have the
> > > optimization toolbox), you could also use fminbnd.
>
> > > a=13.5;
> > > l=48;
> > > crank=0:pi/900:2*pi;
> > > phase=30;
>
> > > positionEX = @(crank) a*cos(crank)+(l^2a^2*sin(crank).^2).^0.5  59.75;
> > > positionIN = @(crank) a*cos(crankphase)+(l^2a^2*sin(crankphase).^2).^0.5  58.75;
>
> > > See that I subtracted off the lower bounds, so you can
> > > just look for zero crossings. Now use ezplot.
>
> > > ezplot(positionEX,[50,50])
> > > figure
> > > ezplot(positionIN,[50,50])
>
> > > Hmm. This points out that both functions are just sine
> > > waves, shifted, scaled, phase shifted. It also indicates
> > > there is NO minimum value of crank that satisfies both
> > > constraints. If you can find one solution, then you can
> > > find infinitely many solutions, all of which are less than
> > > the chosen value. As such, no solver will succeed as you
> > > have currently described the problem.
>
> > > This tells me you need to better define your problem.
> > > Are you looking for the first nonnegative solution?
>
> > > John
>
> > I am trying to find the first 'crank' where both positionEXand positionIN are more than or equal to 59.75 and 58.75 respectively.
>
> > The reason I am trying to do it this way is because I plan to change other variables and loop this code.
>
> But you paid no attention to what I said. Read it again.
>
> If any solution exists, then there will be infinitely many
> of them. There will never be a FIRST solution. You can
> always find a solution that is more negative than any
> given solution.
>
> John Zitierten Text ausblenden 
>
>  Zitierten Text anzeigen 
It seems the OP wants to restrict the variable "crank" to [0,2*pi],
as can be seen by the settings in his first post.
Best wishes
Torsten.
