# Non linear curve fit

## Recommended Posts

Hello,

I have a spectrum from a signal and I know how it should be theorically: A/(1+Bf**2)step(D-f)+E

...where f is frequency.

...where A, B, C, D and E are constants that I want to get from the real data.

To solve this problem I try to use the "Non linear curve fit.vi", but it keeps saying:

Error -20041 occurred at NI_Gmath.lvlib:Nonlinear Curve Fit LM.vi

Possible reason(s):

Analysis: The system of equations cannot be solved because the input matrix is singular.

I checked if the array of independent and dependant values are equal, I checked the fitting model and everything seems ok.

You know why it keeps saying the input matrix has no inverse matrix?

Thank you.

I attached a picture with the VI.

##### Share on other sites

The issue may not be your code but the input data, can you post the vi with minimal default data that demonstrates the issue.

##### Share on other sites

Hello SciWare,

Sorry for the delay. I thought I had posted a message on wednesday but it seems I didn't.

The data wired to the Block is in the next picture. It is a spectrum of a 1/f noise plus a white noise.

I also attach a graph plot of the data contained in the array in the cluster of the spectrum graph.

Nil

##### Share on other sites
Hello SciWare,

Sorry for the delay. I thought I had posted a message on wednesday but it seems I didn't.

The data wired to the Block is in the next picture. It is a spectrum of a 1/f noise plus a white noise.

I also attach a graph plot of the data contained in the array in the cluster of the spectrum graph.

Nil

The last bit of the data seems to be trailing off to 0. That might be the problem.

Neville.

##### Share on other sites

As soon as I come back and get working on this again I'll tell you if your answer is right. However if I remember well, the last data in the graph was non-zero. I'll try to plot a logaritmic graph so that it is easier to see it's non zero.

QUOTE(Neville D @ Feb 9 2007, 06:58 PM)

The last bit of the data seems to be trailing off to 0. That might be the problem.

Neville.

##### Share on other sites

QUOTE(mermeladeK @ Feb 16 2007, 11:39 AM)

As soon as I come back and get working on this again I'll tell you if your answer is right. However if I remember well, the last data in the graph was non-zero. I'll try to plot a logaritmic graph so that it is easier to see it's non zero.

Here I am!

Well, I checked what you said and... it's not about the zeros. I tried a different input for the Nonlinear Curve Fit VI and it keeps saying again the same thing: NI_Gmath.lvlib:Nonlinear Curve Fit LM.vi.

Does any1 have an idea of what is the problem with this VI?

Attached the input waveform:

##### Share on other sites

QUOTE(mermeladeK @ Feb 9 2007, 04:32 AM)

Hello SciWare,

Sorry for the delay. I thought I had posted a message on wednesday but it seems I didn't.

The data wired to the Block is in the next picture. It is a spectrum of a 1/f noise plus a white noise.

I also attach a graph plot of the data contained in the array in the cluster of the spectrum graph.

Nil

Why don't you post the VI's (and data if any) instead of a picture of the BD.. that will save people time in trying to re-build your work just to re-create your error.

Neville.

##### Share on other sites

QUOTE(Neville D @ Feb 26 2007, 10:37 PM)

Why don't you post the VI's (and data if any) instead of a picture of the BD.. that will save people time in trying to re-build your work just to re-create your error.

Neville.

Here are the VI's. The main one is the one with the word "TEST" in the name. The other 2 are subVI's. The "Acquire 1 divided by f idealized spectrum parameters.vi" is the VI supposed to use the Non linear curve fit.

Nil

##### Share on other sites

QUOTE(mermeladeK @ Mar 2 2007, 04:36 AM)

Here are the VI's. The main one is the one with the word "TEST" in the name. The other 2 are subVI's. The "Acquire 1 divided by f idealized spectrum parameters.vi" is the VI supposed to use the Non linear curve fit.

Nil

Thanks,

I will take a look at it shortly.. been out of town and lots to catch up on.

Neville.

Ok,

##### Share on other sites

There are several subvi's missing

Spectrum model.vi

Noise figure to V.vi

Noise from KeV to V.vi

Post them up and we can take a look at it

##### Share on other sites

Yey! You're right. Here they are.

QUOTE(SciWare @ Mar 18 2007, 11:12 PM)

Spectrum model.vi

Noise figure to V.vi

Noise from KeV to V.vi

##### Share on other sites

I took a look at you code but it isn't easy to follow.

I ran it and it produced the reported error which is due to the Lev Mar Curve Fit being unable to calculate a covariance, I'm not sure why though.

What I would strongly suggest is that you check that your curve fit model is correct and that the data that you are trying to fit it to is appropriate. Generate data that fits your model and see if that works, also check your initial coefficients, are they appropriate?

##### Share on other sites

Hi,

Following SciWare suggestions I found the problem. It was about estimating one of the parameters. It still gives me an error which I have to find out why, but it gives a good curve now.

I'll post more about it once I solve the last error.

Thanks.

##### Share on other sites

Awsome

I look forward to seeing it

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

×