LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2-D nonlinear curve fitting

Create an indicator after the read operation to display the read data. After running, right-click the indicator terminal and "change to constant". Delete all code to the left of it and we have a VI with the data built-in.


LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 21 of 63
(2,023 Views)

Nice trick! I'll have to rememeber this one. Update VI is attached.

0 Kudos
Message 22 of 63
(2,016 Views)

Your array to cluster has the output size set to 9 elements (the default), thus it is incompatible with the cluster of 2 elements inside the model. As a first step, you need to set the cluster size to 2 (right-click the array to cluster...cluster size...).


LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 23 of 63
(2,006 Views)

Your data also contains a vertical offset, meaning you need one more parameter.  Just add one more parameter defaulting to 0, and inside the model, expand the initial "index array" by one point and add the output to the array at the very end.

 

I get an offset of 116.043, so for a first try simply subtract that value from your data so you can use the current model. Then implement the offset.

 

 


LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 24 of 63
(2,002 Views)

Here's what I had in mind (LV 2010).

 

 


LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 25 of 63
(1,993 Views)

Also, your data looks quite circular, so you might be able to reduce the model to a single width and also eliminate the rotation.

 

Here's a quick draft.


LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 26 of 63
(1,979 Views)

Is this working for you now?


LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 27 of 63
(1,940 Views)

Altenbach,

 

I am about to use your 2-D nonlinear curve fitting code (or some version of it) to analyze some imaging data that I found today. THANK YOU!!! for posting your code.  Quick question.  Why do you NOT use the mathscript or formula nodes to generate the gaussian model(s)?  I am asking because I might need to implement an assymetrical gaussian model.

 

Rob

0 Kudos
Message 28 of 63
(1,872 Views)

I am a graphical programmer and typically stay far away from any text based code. Smiley Very Happy

 

It should be equally simple to add some asymmetry. What model do you have in mind?


LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 29 of 63
(1,866 Views)

Sorry about the text base code, but essentially an asymmetrical 2D gaussian, like the following, but with rotation as well.  However, keeping graphic, it looks like it should be relatively easy to modify your 2DgaussianRotationModelwithOffset.vi to do the trick, if need be.

 

Again, Thanks for posting your code.

 

Rob

 

%Function f(x,y)
f1 = exp(-0.5*((x-xc)/sigmax1)^2);
f2 = exp(-0.5*((x-xc)/sigmax2)^2);
f3 = exp(-0.5*((y-yc)/sigmay1)^2);
f4 = exp(-0.5*((y-yc)/sigmay2)^2);
if  x < xc
f5 =  f1
else
f5 = f2
end
if y < yc
f6 =  f3
else
f6 = f4
end
z =  offset + amplitude*f5*f6;

0 Kudos
Message 30 of 63
(1,843 Views)