03-07-2002 05:02 PM
03-07-2002 09:39 PM
08-14-2012 06:24 AM
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....
08-15-2012 11:15 AM
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.
08-16-2012 04:33 PM
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)
08-16-2012 04:34 PM
here are the datas again...
08-16-2012 05:48 PM
Hey Patrick,
Please refer to this vi and ignore the other one....this vi is named updated fit...
Thanks,
Marky
08-16-2012 06:57 PM
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.
08-17-2012 04:53 AM
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
08-17-2012 05:12 PM
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)