"Steve" <steve.grikschat@mathworks.com> wrote in message <id0hig$nut$1@fred.mathworks.com>...
> "Colm " <colm.oriordan@tyndall.ie> wrote in message <id08c4$cg7$1@fred.mathworks.com>...
> > "Miroslav Balda" <miroslav.nospam@balda.cz> wrote in message <icph1f$mgf$1@fred.mathworks.com>...
> > > "Colm " <colm.oriordan@tyndall.ie> wrote in message <icol8o$rqu$1@fred.mathworks.com>...
> > > > Hello all,
> > > >
> > > > I'm using fsolve to solve a set of nonlinear simultaneous equations (2 independent variables, 1 dependent variable) which describe the output of an optical modulator. Each equation gives the power of a particular harmonic at the output of the modulator. The goal is to obtain a solution where the power variation across the range of harmonics is a minimum (i.e. variation of power = 0dB). Here is the function code I’m solving using fsolve. It describes the output of the modulator for the fundamental and the first 3 harmonics.
> > > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> > > > function I = MZM_Fun(X)
> > > >
> > > > bias = X(1); %independent variable
> > > > PMI = X(2); %independent variable
> > > > power = X(3); %dependent variable
> > > >
> > > > k = 0; %Harmonic index
> > > > I(1) = ((cos((pi*bias/2)+(k*pi/2)))^2 * (besselj(k,PMI))^2)  2*power;
> > > >
> > > > k = 1; %Harmonic index
> > > > I(2) = ((cos((pi*bias/2)+(k*pi/2)))^2 * (besselj(k,PMI))^2)  2*power;
> > > >
> > > > k = 2; %Harmonic index
> > > > I(3) = ((cos((pi*bias/2)+(k*pi/2)))^2 * (besselj(k,PMI))^2)  2*power;
> > > >
> > > > k = 3; %Harmonic index
> > > > I(4) = ((cos((pi*bias/2)+(k*pi/2)))^2 * (besselj(k,PMI))^2)  2*power;
> > > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> > > >
> > > > Fsolve works fine at finding a minimum to the system of equations given an appropriate initial guess. However, the way I have MZM_Fun set up at the moment means I cannot measure the power variation value from the result as it produces a constant value for ‘power’. What I want to get is an optimized solution for a range of power variation values (i.e. 0dB, 0.5dB, 1dB etc). Can anybody tell me how I can achieve this using fsolve or even fmincon?
> > > >
> > > > Once I can do this I should be able to generate a plot of power variation as a function of either of the independent variables.
> > > >
> > > > Your help is appreciated,
> > > >
> > > > C
> > >
> > > Hi Colm,
> > >
> > > The description of your problem is strange. If you are saying that your independent variables are bias and PMI and the variable power is independent, then you may not put all variables into a vector X of unknowns. X should hold only bias and PMI, which generate a function values which (all four !) are to be equal 2*power (given fixed value). Vector I is a vector of residuals of the four equations. Therefore, dependent variable power should be transfered to the function by another way, say as a global variable or through a nested function.
> > >
> > > You say that "Fsolve works fine at finding a minimum to the system of equations". I can't imagine that you have got good results with a wrong vector X.
> > >
> > > In general, your residuals are defined as
> > > I(k) = f(bias,PMI,k)  2*power;
> > > It means that the power of independent variables is f(bias,PMI,k). Are you looking for such solutions, which are for all k inside an interval power+Delta(power), where Delta(power) comes out of selected variations ?
> > >
> > > You see, that there are inportant things to be explained.
> > > Good luck.
> > >
> > > Mira
> >
> > Hi Mira,
> >
> > Thanks for the reply. Yes I think what you describe is what i'm looking to achieve. So as a first step I need to pass power as a fixed value to function MZM_Fun and not as an initial guess value in vector X. Is the 'delta (power)' value as you say related then to the residuals of each equation?? I'm just not clear on how to set up the function to give me this result :(
> >
> > Regarding my comment that fsolve works fine, the function as outlined in my original post gives me a solution with a fixed value for power and acceptable results for PMI and bias which I have verified by simulation using another program.
> >
> > C
>
> I can't be certain, even with the prior discussion, but it seems that you would pass power as a fixed additional parameter to MZM_Fun and then measure the residuals at the solution given by fsolve. The residuals tell you how close you are to your target power (delta_power).
>
> An alternative may be solving several times for a wider range of power values (fixed at each attempt to solve). This makes sense if fsolve cannot achieve a certain power value. Does this sound right?
>
> Steve
Hi Steve,
Yes you are quite correct. This works as you say and i can measure the power variation values from the residuals once you pass an appropriate value of power to MZM_Fun.
I am now trying to solve the equations in MZM_Fun for a range of fixed PMI values so i can plot power variation as a function of PMI. What is the best way to acheive this?
If i pass PMI along with power as additional paramaters to MZM_Fun how will this affect the residual values? Also if for a particular PMI value the best power variation value is quite large what options of fsolve do I have to adjust so I get a solution in this case?
Thanks again
C
