LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2d Lev-Mar Example

I am trying to fit an equivalent circuit model to measured data.  The data is a standard DC family of curves where the x-axis is the drain voltage and the y-values are drain currents for multiple gate voltages.  Thus the function will depend on the drain voltage and the gate voltage to determine the drain current.

 

I have searched the examples and message boards and only found some very confusing examples of Lev-Mar multivariate fitting.  I have done this in Excel with the solver, but Excel tends to crash and is slow.  The measured data is in text format and I have made a manual fitting routine in Labeled.  I hope to convert it to an automated optimizer.

 

Thanks,

Fred

0 Kudos
Message 1 of 9
(3,728 Views)

Over the years, I posted quite a few examples and I don't think they are too difficult. So let's simply clear up the confusion instead. 😄

 

Do you have some typical data and a detailed description of the model? How many fitting parameters do you have?

Message 2 of 9
(3,726 Views)

I have example data and can provide an example equation showing what the parameters are.  There are roughly variable parameters that are adjusted to fit the data.

 

Here is a very shortened form:

 

Id=P1*(tanh(P2*Vd/(P1*(1-P3*(Vg)))));

 

I pulled most of the equation to keep it simple.

 

Again, Vd and Vg are independent variables and P1 - P3 are the constants I want to adjust to fit the measured data.

 

I can send a picture of what the measured data plot looks like if you need it.

 

Thanks,

Fred

0 Kudos
Message 3 of 9
(3,710 Views)
Please also attach some sample data. What are reasonable estimates for P1..P3? What is your LabVIEW version?
0 Kudos
Message 4 of 9
(3,705 Views)

I did a quick modification of my old NI-Week Demo (using simulated data) and the fit seems to work quite well.

 

Here's an example fit:

 

 

Here's the code of model subVI:

 

 

All you need to do is add some code to read in real data. 🙂

 

Let me know what LabVIEW version you have and I attach the code.

Message Edited by altenbach on 01-06-2009 02:11 PM
Download All
Message 5 of 9
(3,695 Views)

I have version 7.1 here...we have newer versions in the lab.

 

I have been tied up this afternoon....

 

thanks

0 Kudos
Message 6 of 9
(3,691 Views)
You need at least LabVIEW 8.0. Anything lower requires significantly more effort.
Message 7 of 9
(3,687 Views)

I have reviewed you code and the light turned on!  I kept trying to pass Vd and Vg into the equations.  You still use "X" and use it to index the data.  I will give this a try!

 

Thank you very much,

Fred

0 Kudos
Message 8 of 9
(3,659 Views)

Yes, fortunately the size of the x array does not need to match the size of the z array, so all you need to do is make sure that your function has all the x and y data one way or another. One possibility is to interleave the two in the toplevel program and then split them again using "decimate array" in the model (as I did). You could equally well append the two and then split the array later. As long as it is a 1D array and both sides know how things are arranged, you're fine.

 

Another possibility would be to not even use the x-array input, but send the x and y arrays via the "data" variant.

 

All you need is a model VI that generates a Z array to be compared with a matching Z array of your experimental data based on the fitting parameters. 🙂

Message 9 of 9
(3,646 Views)