LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Nonlinear Curve Fit Error

I am trying to get a multi-dimensional fit working by using a nonlinear curve fit VI and everytime I run it I get an error saying that my samples need to be greater than 0. The specific error message is: "Error: Analysis samples need to be > 0." Does anyone know what is wrong? I have tried to reinitialize my input parameter array to zero, recompile the VI, etc. and still get the same error regardless.

 

I have attach all my VI's.

 

Thanks,

 

Ynessa 

0 Kudos
Message 1 of 8
(3,201 Views)

Can you put some typical values into all controls, make them the default, and attach it once more so we have something to play with? Thanks.

 

(And please eliminate the local variables in the loops of the model. Just use a wire. Why do all your panels and diagrams fill half of a gigantic screen? I typically like to see more than one panel or diagram at once.)

0 Kudos
Message 2 of 8
(3,193 Views)

For  starters, your model uses 8 elements of the paramter array, but you are only giving it 6 ("initial parameter" input). This you need to fix first.

 

You also need to disconnect the f'(X,a) indicator in the model subVI. What you wire there has nothing to do with partial derivatives and will confuse the fitting algorithm. You cannot arbitrarily re-use that output for e.g. your parameter estimates algorithm. The fitting algorithm expects partial derivatives or an empty array output. If the array is empty, it will calculate numerical derivatives externally. If the output is non-empty, it assumes these are partial derivatives.

0 Kudos
Message 3 of 8
(3,167 Views)

You also should NOT add noise inside the model. The model needs to be noise-free and purely based on the input parameters. To add noise to the simulation, call the model once, then add noise before fitting.

0 Kudos
Message 4 of 8
(3,157 Views)

The typical values for the controls are as follow:

Pixel Size (um) = 5.2

x0 (mm) = 640

y0 (mm) = 512

Focal Length (mm) = 1000

Wavelength (mm) = 561

Beam Diameter = 1

Amplitude = 100

Background Amplitude = 10

 

Width = 1280

Height = 1024 

 

I am farely new to labview and have not figure out the best way, so that my diagrams stay smaller since my width and height are farely large. What do you mean eliminate the local variables in the loops of the model? 

0 Kudos
Message 5 of 8
(3,134 Views)

ytran wrote:

I am farely new to labview and have not figure out the best way, so that my diagrams stay smaller since my width and height are farely large. What do you mean eliminate the local variables in the loops of the model? 


In the model, you have a hidden indicator called pixel size, which you write once outside the loop and then continuously read over and over again with every iteration of the loops via local variables. SInce the value does not change during the execution of the loops, reading the same indicator over and over is just a waste of efforts. Why involve the UI if the valie is right there in the wire?? The correct way would be to delete that indicator and the local variables and simply connect all by wires.

 

Did you understand my other comments?

 


@ytran wrote:

The typical values for the controls are as follow:

Pixel Size (um) = 5.2

x0 (mm) = 640

y0 (mm) = 512

Focal Length (mm) = 1000

Wavelength (mm) = 561

Beam Diameter = 1

Amplitude = 100

Background Amplitude = 10


Are all of those fitting parameters or are some of them constant and known?

0 Kudos
Message 6 of 8
(3,124 Views)

I am not really sure what you meant about disconnect the f(X,a) indicator in the sub VI model, can you clarify that part. 

 

The pixel size, focal length, wavelength, and beam diameter are known. The focal length, wavelength, and beam diameter will help me calculate the sigma x and sigma y for the fittings. 

0 Kudos
Message 7 of 8
(3,096 Views)

You wired the 2D array to the f '(X,a) output. You need to disconnect that wire because it does not make any sense.

 

Did you understant all my other points?

 

You still have a mismatch between the number of parameters.

If the pixel size, focal lenght, and wavelength are constants, they cannot be part of the parameter array. You can relay them to the model via the variant data connecter. Just add more elements to the cluster and convert back from variant accordingly.

0 Kudos
Message 8 of 8
(3,080 Views)