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

"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

"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

"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

"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

You can think of your watch list as threads that you have bookmarked.

You can add tags, authors, threads, and even search results to your watch list. This way you can easily keep track of topics that you're interested in. To view your watch list, click on the "My Newsreader" link.

To add items to your watch list, click the "add to watch list" link at the bottom of any page.

To add search criteria to your watch list, search for the desired term in the search box. Click on the "Add this search to my watch list" link on the search results page.

You can also add a tag to your watch list by searching for the tag with the directive "tag:tag_name" where tag_name is the name of the tag you would like to watch.

To add an author to your watch list, go to the author's profile page and click on the "Add this author to my watch list" link at the top of the page. You can also add an author to your watch list by going to a thread that the author has posted to and clicking on the "Add this author to my watch list" link. You will be notified whenever the author makes a post.

To add a thread to your watch list, go to the thread page and click the "Add this thread to my watch list" link at the top of the page.

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.

Got questions?

Get answers.

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreDiscover what MATLAB ^{®} can do for your career.

Opportunities for recent engineering grads.

Apply TodayThe newsgroups are a worldwide forum that is open to everyone. Newsgroups are used to discuss a huge range of topics, make announcements, and trade files.

Discussions are threaded, or grouped in a way that allows you to read a posted message and all of its replies in chronological order. This makes it easy to follow the thread of the conversation, and to see what’s already been said before you post your own reply or make a new posting.

Newsgroup content is distributed by servers hosted by various organizations on the Internet. Messages are exchanged and managed using open-standard protocols. No single entity “owns” the newsgroups.

There are thousands of newsgroups, each addressing a single topic or area of interest. The MATLAB Central Newsreader posts and displays messages in the comp.soft-sys.matlab newsgroup.

**MATLAB Central**

You can use the integrated newsreader at the MATLAB Central website to read and post messages in this newsgroup. MATLAB Central is hosted by MathWorks.

Messages posted through the MATLAB Central Newsreader are seen by everyone using the newsgroups, regardless of how they access the newsgroups. There are several advantages to using MATLAB Central.

**One Account**

Your MATLAB Central account is tied to your MathWorks Account for easy access.

**Use the Email Address of Your Choice**

The MATLAB Central Newsreader allows you to define an alternative email address as your posting address, avoiding clutter in your primary mailbox and reducing spam.

**Spam Control**

Most newsgroup spam is filtered out by the MATLAB Central Newsreader.

**Tagging**

Messages can be tagged with a relevant label by any signed-in user. Tags can be used as keywords to find particular files of interest, or as a way to categorize your bookmarked postings. You may choose to allow others to view your tags, and you can view or search others’ tags as well as those of the community at large. Tagging provides a way to see both the big trends and the smaller, more obscure ideas and applications.

**Watch lists**

Setting up watch lists allows you to be notified of updates made to postings selected by author, thread, or any search variable. Your watch list notifications can be sent by email (daily digest or immediate), displayed in My Newsreader, or sent via RSS feed.

- Use a newsreader through your school, employer, or internet service provider
- Pay for newsgroup access from a commercial provider
- Use Google Groups
- Mathforum.org provides a newsreader with access to the comp.soft sys.matlab newsgroup
- Run your own server. For typical instructions, see: http://www.slyck.com/ng.php?page=2

Choose your country to get translated content where available and see local events and offers. Based on your location, we recommend you select **United States** from the following list:

- Canada (English)
- United States (English)

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)