help-octave
[Top][All Lists]
Advanced

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

Nonlinear Equation/fminsearch question


From: Rick T
Subject: Nonlinear Equation/fminsearch question
Date: Sat, 22 Oct 2011 23:52:31 -1000

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


reply via email to

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