LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Natural logarithm which curve fit to use?

Solved!
Go to solution

My love affair with calculus ended quickly and I am now in need of it.

I need to know the formula for my descending line.

I am told to use y= -a lnX +b (best fit).

An image of my signal is attached.

There MUST be a canned fit vi that does this.

Is there?

0 Kudos
Message 1 of 14
(2,920 Views)

You can use nonliner curve fit for any kind of model. I somehow doubt that y= -a lnX +b will describe your data, though. Can you attach a typcal xy data file? What is your LabVIEW version?

 

There is also an express VI if you are into these kind of things. :D.

 

0 Kudos
Message 2 of 14
(2,907 Views)

Thanks.

I am trying to build it in the express vi (don't cringe)!

The 2011 vi is attached

0 Kudos
Message 3 of 14
(2,889 Views)

You did not wire the locations input, so the express VI assumes an X array starting with zero. The log of zero is NaN, thus the fit fails. I modified your code to suply an explicit x array starting with 1. (see attached)

 

The fit completes, but the model is definitely not sufficient to describe the data. You might also try some more reasonable starting values for the parameters.

0 Kudos
Message 4 of 14
(2,883 Views)

I have not modified your code, but there are some weird constructs. Don't abuse "delete from array", retaining only the deleted portion to simulate the more appropriate "array subset" function.

0 Kudos
Message 5 of 14
(2,879 Views)

I think it is correct.

I will have to glue it into the rest of the larger vi to see but the curve plot does look like it is supposed to.

 

News at 11

0 Kudos
Message 6 of 14
(2,877 Views)

Not sure what you mean by 'abuse' delete from array. Should I just extract what I need and not delete?

 

It might be better to read the whole intention of what I am trying to achieve. It is attached

0 Kudos
Message 7 of 14
(2,874 Views)

Oops, wrong file.

This one is correct, it's been that kind of day 🙂

 

0 Kudos
Message 8 of 14
(2,873 Views)

@Murph wrote:

Not sure what you mean by 'abuse' delete from array. Should I just extract what I need and not delete?


 

Don't worry, it's just one of my pet peeves 😄

 

"Delete from array" is a more complicated function, because it generates two different outputs: (1) the original array with a portion deleted (2) the deleted portion.

 

Since you are only interested in the deleted portion (which is a subset of the original array for all practical purposes), the "array subset" function seems more appropriate.

 

We can only hope that the compiler is smart enough to skip the unneeded internal steps inside "delete from array" if one of the output is no connected, but who knows. 😉

 

To me it feels like a chef using a swiss army knife in the kitchen to chop the onions instead of a more appropriate tool. Sure it works, but there could be performance issues. Well, at least he's not using nail clippers 😄

 

I still don't understand why you think that logX is suitable at all, the fits looks horrible. You don't define X. Aren't there some real values involved.

 

0 Kudos
Message 9 of 14
(2,867 Views)

I get it. I am obviously not a regular programmer. I fight my way through and eventually get it to work, often in a round about way.

 

As for the function. It was not done by me. What this data is comes from a gas detector. It is pumped thru the detector with a known concentration and it's area is calculated over time. An unknown is then run and it's area is compared to the known one to determine it's concentration. We screwed around with many many, did I say many? ways of calculating the area, none with accuarcy.

A chromatography chemist came up with the method described in the Word document. I've built everything else, I just need to do a best fit from the apex of the curve to the end to determine a proper place to stop. According to the chemist, this is a common method for gas measurements.

Make any sense?

0 Kudos
Message 10 of 14
(2,857 Views)