LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

lorentzian curve generation

Hello,

 

Is there a way to generate a lorentzian function in labview ?

I'm using labview 2014..

 

Thanks

0 Kudos
Message 1 of 7
(982 Views)

Yes, just generate an ramp of x values and apply the formula. What is giving you problems?

0 Kudos
Message 2 of 7
(973 Views)

@rmayer wrote:

Is there a way to generate a lorentzian function in labview ?


Sure.  A Lorenzian has three parameters:  Amplitude (A), Peak Center (x0), and Width at Half Peak (WHP)  Write a sub-VI that takes a Cluster having A, x0, and WHP as "fixed parameters" (which define your curve), and pass "X" in as the main (upper-left) parameter.  To draw the curve from, say, 0 to 1 with parameters [1, 0.5, 0.3] (which means the peak is 1, it is centered at 0.5, and if you measure its width at 0.5, half the peak value, it will be 0.3), put a range of points, say 0, 0.01, 0.02, ... 0.98, 0.99, 1.0 through this function, using the points as the X coordinate of your plot, and Lorentzian (X) as the Y of your plot.

Do you know how to create a sub-VI (which you can think of as a "Function")?  There are some LabVIEW functions called "Ramps" (do a search for this) that can generate for you the X values.  Do you know how to use a FOR or WHILE structure to step through an orderly series of values, such as generating X, Y pairs for a plot?  Do you know how to plot a Chart or a Graph?

 

Bob Schor

0 Kudos
Message 3 of 7
(967 Views)

Thanks, it's OK, I managed to create a vi that is doing what I need.

Thanks for your advices

0 Kudos
Message 4 of 7
(924 Views)
0 Kudos
Message 5 of 7
(923 Views)

A few comments:

 

  • A toplevel UI loop requires a small wait. No need to spin it millions of times per second burning your CPU. How quickly can you possibly enter new values???
  • Never maximize the front panel and diagram to the screen, especially for such small code. You should be able to see both, as well as the help window at the same time.
  • You can use complex values for an xy graph, no need to bundle. You can actually use a waveform graph once you correctly set x0 and dx (not shown).
  • You might want to create a special case if the width is zero, a result of all zeroes with a NaN in the center is not helpful (not shown).

 

Here's what I might do.

 

altenbach_0-1665099081397.png

 

0 Kudos
Message 6 of 7
(883 Views)

From the icon it seems you started with the template for nonlinear fitting. If you want to fit this curve to data, you cannot change the connector pane, so here's how the model could look like.

 

altenbach_0-1665100489735.png

 

0 Kudos
Message 7 of 7
(878 Views)