LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I need assistance entering an equation correctly into a formula node for curve-fitting.

Thank you so much, that's a large step in the right direction. However as you can see by the VI's I've attached, the results I obtain from running Nonlinear Fit 2.vi are not at all what I had hoped for. You can see what the raw data looks like by running Poling Data Reader 5g.vi. The best fit should at least somewhat resemble it. Can you see anything I'm still doing wrong?

Thanks again for your help!
Download All
0 Kudos
Message 11 of 30
(1,336 Views)
Swordfish,
I am glad I could be of any help here. Let me see if we can tackle the last inch as well...I did run your data reader using a film thickness of 50 um (the default value was set to 0). I then get a result that I attached in the gif file below. This data show hysteresis for the J(E) relation. Is that correct? If so, what region do you want to model with your equation? I am asking because I do not think I understand exactly what you want to accomplish with your fitting procedure since your equation is a linear curve with a superimposed exponential increase. Please fill us in with more details and I am sure we will make you a happy camper with LabVIEW on your side. /Mikael Garcia
0 Kudos
Message 12 of 30
(1,336 Views)

Hi Mikael,

 

I was just going through this thread to get some help for my project.

In the project I am working on I have a set of data points(12points) as strings. One is time data and the other being angle data. I managed to plot the graph converting from strings to 1D array. BUt NOW i need to fit a non-linear sine fit using the fourier series equation like " y = a1*sin(2*3.14*f*x+c1)+a2*sin(2*2*3.14*f*x+c2)+a3*sin(3*2*3.14*f*x+c1)+a4*sin(4*3.14*f*x+c4)+a5*sin(5*3.14*f*x+c5) "

 

Here x is the input from the time data which is given as Independent.txt

f is the frequency which will be controlled by the user from the front panel. (for this data set f=100hz)

c is the phase coefficients and

a is the amplitide coefficients.

 

In my Vi the first for loop can be ignored. But the nonlinear fit is what i am looking for.

 

I have attached my Vi file and the txt files.

 

Please help me out wit this. It would be greatly appreciable!!!

 

Thanks....

Download All
0 Kudos
Message 13 of 30
(1,081 Views)

Hi Marky,

 

After reviewing your VI most things look good except your use of the General Linear Fit VI. Based off your post I believe that you wish to do a non-linear fit. I would try the non-linear curve fit VI which uses the Levenberg-Marquardt algorithm as described previously in this forum post. I would also recommend acquiring more data points if possible to improve the result of the fit. If you continue to have problems please post your updated VIs and I will take another look. 

Patrick H | National Instruments | Software Engineer
0 Kudos
Message 14 of 30
(1,057 Views)

Hey Patrick,

 

Thanks somuch for your reply. Since I am relatively knew to Labview , Inspite of trying somuch I  still did not figure out properly how to do a sine series fit to my samples using the L-M curve fitting.

 

1)As you had mentioned I would like to get more data points out of my unevenly placed samples. I tried using numeric integrator(but couldnt figure out how to go ahead with this). Second I tried interpolation but that does not really serve the ultimate purpose of my project. I need much more reliable values. 

 

2) I need to fit a sine series fit and verify howmuch my actual data points deviate from the sine fit. (I could not perform the sine fit yet to compare this:/ )...

 

My ultimate aim is to get the amplitude (i.e the maximum of the sine fit coeefiecient) as a result...

 

I am attaching the vi and txt files again to show you how far I have got.But in the fit(just one sine fit) I tried doing, the coefficients  are pre-defined(I guess) as a,b and c , which should not be the actual case.I need to get them out as a result aswell..

It would be of great help if you could throw light into this..Because I have been stuck with this for a long time and end of this month is my dead line... Any help would be a big deal!!!

 

Thanks,

 

Marky

 

(P.S : i am attaching a diagram which is idealy the result I am looking for , the red dots are my data points and the green is the sine series fit)

Download All
0 Kudos
Message 15 of 30
(1,042 Views)

here are the datas again...

Download All
0 Kudos
Message 16 of 30
(1,042 Views)

Hey Patrick,

 

Please refer to this vi and ignore the other one....this vi is named updated fit...

 

Thanks,

 

Marky

0 Kudos
Message 17 of 30
(1,035 Views)

Hi Marky,

 

Please provide the create_ramp VI so I can better assist you. I am not as familiar with what you are trying to do mathematically but I am going to get caught up on that while I wait for that VI. Being new to LabVIEW I encourage you to use the Highlight Execution feature as well as the wire Probe feature for debugging purposes.

Patrick H | National Instruments | Software Engineer
0 Kudos
Message 18 of 30
(1,025 Views)

Hey Patrick,

 

I have attached the "create ramp" file for your reference...

 

I could just explain little more in detail about my project if it would help you to help me better:)

 

1) I have 6 photodiodes which gives me 12 time datas from a laser illumination reflected from an oscillating mirror...Through a DAQ i get these datas into my GUI. (x-axis)

 

2) These photodiodes are arranged on a PCB and each have a particular position by which they are seperated. So now I have the y axis which is my position(amplitude) information.

 

3) I need to measue the amplitude at the resonant frequency of my mirror. Since I only have few uneven samples from the photo diode arrangement , I was hoping to fit a sine series fit (this gives me the harmonic coefficients aswell) and find the amplitude.

 

4) As mentioned earlier , since I already know  the resonant frequency of my mirror i want to control it from the front panel itself and so basically i should have two unknown coeffecients for one sine term i.e the amplitude and phase.

 

Is it possible to achieve this using the formula node?? I tried it, but was not succesful:/....

 

Hope you can help me some way!! 

 

Thanks,

 

Marky

0 Kudos
Message 19 of 30
(1,020 Views)

Hi Marky,

 

After discussing with a colleague we have come up with an idea for you. Since you are trying to do a trig regression, you could try to linearize your data points to perform a linear regression. Then apply the inverse transformation again in order to have a trig function.

 

DATA: y = sin(x)   -> linearize data: arcsin(y) = x -> linear regression: arcsin(y) = ax + b ->Reapply trig function: y = sin(ax + b)

Patrick H | National Instruments | Software Engineer
0 Kudos
Message 20 of 30
(996 Views)