06-30-2010 10:04 AM
I have a program in which I get a response signal that is of the form A*cos(w*t)*exp(-t/T2), where A is amplitude, w is frequency, t is time, and T2 is spin relaxation time. Is there any way to fit a curve to this graph and ouput the values of the variables? I have tried many of the options in labview but cannot seem to find a way to add the T2 variable.
Thanks,
Justin
Solved! Go to Solution.
06-30-2010 10:57 AM
Hi!
Try using the "Curve Fitting" Express vi.
By selecting "Non-linear fit" in the configuration panel you can define your own fitting function with all your three parameters.
Marco
06-30-2010 12:26 PM
For some reason every time I try to enter my formula into the non-linear model input box the indicator to the right turns red and it doesn't allow my inputted equation. I am fairly certain that the form in which I inputted the equation is correct so I am not sure what the problem is unless it does not work with both cosine and exponential fxns or something of that nature.
Thanks,
Justin
06-30-2010 01:11 PM
Disregard my second post. You are right, Marco, it works, I'm not sure what I was doing wrong before. But, I have related question. Is there any way to get the VI to output the final values of the variables after the curve has been produced? Or is there another way to fit a curve that would do this?
Thanks,
Justin
06-30-2010 01:27 PM
My last choice would be the Express VI, my next-to-last choice is to use the Nonlinear LM fit with a formula string as the input. Still an improvement (IMO) over the Express VI. If I had to guess about your previous trouble, it is probably that you were using A and T2 as variables instead of a and t2.
Here is a quick example to generate fake data and fit it to your function.
06-30-2010 01:42 PM
I should have mentioned I am on labview 8.6. Is there any way that you could attach that in as an 8.6 compatible version or attach a screen shot of the block panel?
06-30-2010 01:44 PM
LV8.6
07-02-2010 10:37 AM
I am not sure how to draw out the x and y arrays from my response to input into the Lev-Mar vi that you used in your example. My response signal is waveform(DBL) that is outputted from a DAQmx read vi. I have attached my vi along with the necesary subvi's. The one in question is Signal and Response. The data that needs a curve fit is outputted from the Record.vi subvi.
07-07-2010 12:14 PM
Hi Justin,
If the data is in a waveform format, you can use "Get Waveform Components" to extract out dt, t0, and Y values. If you need an array of X, you can use the dt and t0 values to build it.
Cheers,
07-08-2010 08:09 AM
It turns out he real reason it wasn't working when I tried all of your suggestions was a hardware issue. Thank you all very much for your time and help!
Justin