LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Making a multidimensional fit faster

I have this multidimensional fit VI that works it is taking about 30 seconds for the waveform to fit. Does anyone have any suggestion of making it faster? 

In my 2D Gaussian Model I have the 2D gaussian equation with 2 forloops, this is taking about 1 whole seconds for it to calculate and might be the reason it is slowing the code down is there a different way of having this exact model? 

 

Thanks. 

0 Kudos
Message 1 of 2
(2,166 Views)

Your model VI repeats many calculations unnecessarily. The image below was taken with "constant folding" turned on. The fuzzy lines are value which do not change within one iteration of the loop. Therefore, all that should be moved outside the loop. Why calculate it a million times when a thousand will do?

 

Constant folding.png

 

Then I looked at other things and found a few more repetitions which could be avoided. For example the size of the output array can be calculated from Width x Height. No need to measure the size of the 2D array.

 

The attached Model VI seems to run in about 2/3 the time of the original.

 

Lynn

 

0 Kudos
Message 2 of 2
(2,142 Views)