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.

Hey Patrick ,

 

Thanks somuch for taking some time out to see my problem....

 

Hmmm...I am a little lost here...

 

1) Is this trignometric function used to obtain the coefficients a and b... Then to find the value of y at intervals of x ?

 

2) After performing the linear regression , then I can apply my sine series function to the values?

 

3) I am little confused where to start from aswell...

 

I am sorry but could you explain me little bit more in detail....

 

Thanks a ton again,

 

Marky

0 Kudos
Message 21 of 30
(1,017 Views)

Hi Marky,

 

Sorry for the confusion. The technique I am using is something I have done in the past for exponential functions. My understanding is the data you will be analyzing should follow a sin function.

 

Your data is: y = sin(x)

 

The first step is to linearize your data by taking the arcsin of both sides leaving you with:

 

arcsin(y) = x

 

With a linear piece of data you can then do a linear regression to get A and B:

 

arcsin(y) = ax + b

 

Then reapply the trig function:

 

y = sin(ax+b)

 

I think this should accomplish what you need but if not we may need to look into alternative signal processing techniques.

 

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

Hey Patrick,

 

Thanks somuch for the details... I am working on this now as an alternative and incase I face some difficulties I will let you know...

 

But meanwhile, I have already developed a routine using the L-M curve fitting. It works fine but I am facing some issues which makes me feel its not very relaible...I will explain you what i have done in this vi ....

 

1) I have used a ramp pattern.vi to generate x values and given to call by reference and connected my function to it to generate y values values coressponding to it.

 

2)1) I have used Re/Im To Complex Function to make a complex function of both the x and y (original and generated data) and ploted the graph

 

3) My function is of the form y = a0*sin(2pi*f*x+a5) + a1*sin(2*2pi*f*x+a6) + a2*sin(3*2pi*f*x+a7) + a3*sin(4*2pi*f*x+a8) + a4*sin(5*2pi*f*x+a9)

 

where a0...4 are the harmonic amplitude coefficients and a5...9 are my phase coefficients... Since data points were from a 100hz mirror , the frequency supplied at the fit.vi front panel is 100...

 

Every thing worked so far so good...

 

But, 

 

Can you please check the results with  the fits by changing the red terms in the equation : "y = a0*sin(2pi*f*x+a5) + a1*sin(2*2pi*f*x+a6) + a2*sin(3*2pi*f*x+a7) + a3*sin(4*2pi*f*x+a8) + a4*sin(5*2pi*f*x+a9) " and

y = a0*sin(2pi*f*x+a5) + a1*sin(3*2pi*f*x+a6) + a2*sin(5*2pi*f*x+a7) + a3*sin(7*2pi*f*x+a8) + a4*sin(9*2pi*f*x+a9) 

They give me different results??

 

I am getting an ideal fit with higher harmonic equation y = a0*sin(2pi*f*x+a5) + a1*sin(3*2pi*f*x+a6) + a2*sin(5*2pi*f*x+a7) + a3*sin(7*2pi*f*x+a8) + a4*sin(9*2pi*f*x+a9)...

 

where as with y = a0*sin(2pi*f*x+a5) + a1*sin(2*2pi*f*x+a6) + a2*sin(3*2pi*f*x+a7) + a3*sin(4*2pi*f*x+a8) + a4*sin(5*2pi*f*x+a9) i am not getting a good fit (this is the equation what i actually need the fit for)....

 

I will attach my vis along with this mail..Can you please please look into it and see me where have i gone wrong...or any feedback will be appreciable...

 

Thanks a ton,

 

Marky

Download All
0 Kudos
Message 23 of 30
(993 Views)

Hey Marky,

 

I have looked into this issue some more and this may be an issue with your method. You may need to look into doing Fourier Analysis on this data. There are different VIs that allow you to do this analysis in the signal processing palette. Also, look under the help menu, find examples, and search FFT to find an example if you are not familiar with FFT.

 

Patrick H | National Instruments | Software Engineer
0 Kudos
Message 24 of 30
(981 Views)

Hey Patrick,

 

Thanks for your patience...I will check the fourier analysis examples and if its no problem, i will post if I have any further issues with it...

 

Thanks again,

 

Marky

0 Kudos
Message 25 of 30
(977 Views)

Hey patrick,

 

I have another issue with the designed curve fitting vi. Actually this problem occurred when I shifted the vi file after converting from my personal comp using  English version 12.0 to my office comp using German version 8.5...

 

The error on executing the vi shows "The system of equations cannot be solved because the input matrix is singular. "

 

I used the probing tool to see if my string values are being send properly...I found one of the errors there..The X  values are being send as zeros and the Y values(no values after the dot) ... I believe the whole problem is because I am using a german software....Could you provide me any suggestions to come over this problem if I am using a German system?

 

Thanks somuch,

 

Marky

Download All
0 Kudos
Message 26 of 30
(969 Views)

Hey Patrick,

 

I have fould the problem out and have solved it...I just had to make a small change in the format string and it was fine....

 

Thanks again,

 

Marky

0 Kudos
Message 27 of 30
(956 Views)

Please, correct my mistake.

0 Kudos
Message 28 of 30
(933 Views)

for some reason you added to a LabVIEW thread about curve fitting with a multisim question that is completely offtopic here. (Is this the mistake you want us to find? :D)

 

Please post in the multisim forum instead. I would also strongly recommend to add a few more sentences to your post. The four words "please correct my mistake" don't give enough information on what you are looking for and what the problem is.

0 Kudos
Message 29 of 30
(927 Views)

ok ok.....

 

0 Kudos
Message 30 of 30
(911 Views)