help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Nonlinear Equation/fminsearch question


From: Juan Pablo Carbajal
Subject: Re: Nonlinear Equation/fminsearch question
Date: Sun, 23 Oct 2011 13:07:14 +0200

On Sun, Oct 23, 2011 at 11:52 AM, Rick T <address@hidden> wrote:
> Greetings All
> I have several equations and each have their own individual frequencies and
> amplitudes. I would like to sum the equations together and adjust the
> individual phases, phase1,phase2, and phase3 to keep the maximum amplitude
> value of eq_total under a specific value like 0.79. I know I can normalize
> the signal, but for my purposes I need to have this controlled by
> changing/finding the values for just the phases in phase1,phase2, and phase3
> that will do this.  I have some code below using fminsearch but when I put
> the phases back in and plot the values, the max amplitude is much more than
> 0.79 any ideas what I'm doing wrong?
>
> Example:
> eq1=0.2*cos(2pi*t*3+phase1)+verticaloffset
>
>
> eq2=0.7*cos(2pi*t*9+phase2)+verticaloffset
>
>
> eq3=0.8*cos(2pi*t*5+phase3)+verticaloffset
>
>
>
> eq_total=eq1+eq2+eq3
>
> The Code I have is below
>
> t=linspace(0,1,8000);
>
> verticalOffset=0;
>
> objectiveFunction =
> @(phase)(max(abs(0.2*cos(2*pi*t+phase(1))+0.7*cos(2*pi*t*9+phase(2))+0.8*cos(2*pi*t*5)+verticalOffset))
> - 0.79)^2;
>
> s1 = fminsearch(objectiveFunction,[0;0])
>
> eqt=0.2*cos(2*pi*t+s1(1))+0.7*cos(2*pi*t*9+s1(2))+0.8*cos(2*pi*t*5)+verticalOffset;
>
> plot(eqt)
>
> thanks sal22
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
>
>

Your cost function is symmetric around amplitude 0.79, so solutions
with higher amplitudes are allowed. You should use sqp for this kind
of optimization, or work with the algebraic expression of the analytic
function (hilbert transform) which gives you the amplitude of your
signal and optimize that. The latter is possible if your combination
is of a small number of functions, otherwise is too messy. For the
general case use sqp and put the constraints in the amplitude.

Cheers



-- 
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]