LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Curve Fitting in LabView

Hello all,

I'm trying to use the Levenberg-Marquardt.vi to fit some data. The
equation to which I'm trying to fit it must be entered in a "model
cluster". It keeps giving me a 'parsing' error (-23001). Am I entering
the equation incorrectly?
It looks like this y=A*x^4+B*x^2+C+D*x(-2)+E*x^(-4). The curve fitting
vi is reading the data fine but it's not spitting anything out (best
fit).

Any thoughts or comments would be appreciated.

Thanks
k
0 Kudos
Message 1 of 8
(4,423 Views)
Kieran,

Could the problem be the fact that you forgot the '^' symbol on the 'D*x(-2)" item? Other than that, I don't see anything wrong with your equation.

If you're still having problems, you can post your VI and I can take a look to see what the problem might be.

Good luck, and have a pleasant day.

Darren
0 Kudos
Message 2 of 8
(4,422 Views)
Kieran wrote:
>
> Hello all,
>
> I'm trying to use the Levenberg-Marquardt.vi to fit some data. The
> equation to which I'm trying to fit it must be entered in a "model
> cluster". It keeps giving me a 'parsing' error (-23001). Am I entering
> the equation incorrectly?
> It looks like this y=A*x^4+B*x^2+C+D*x(-2)+E*x^(-4). The curve fitting
> vi is reading the data fine but it's not spitting anything out (best
> fit).

1: You could just simplify this equation till it works, thus finding the
problem yourself!
As someone else wrote, it probably should be D*x^(-2).

2: Or rewrite the formula; using divide symbols lets you remove the
brackets & clarify the formula. Easier to spot errors:
y=A*x^4 + B*x^2 + C + D/x^2 + E/x^4

3: If this subVI accepts multi-
line formulae you might get better
execution speed with intermediate numbers, and using * instead of ^2.
That's certainly true with some compilers:

v=x*x
w=v*v
y=A*w + B*v + C + D/v + E/w

4: Or separate by semicolons to put it on 1 line:

v=x*x; w=v*v; y=A*w + B*v + C + D/v + E/w

Best, Mark
0 Kudos
Message 3 of 8
(4,422 Views)
The thing that really stands out is your power syntax. Starting with labview 6i, the format for a power is now x**4 for x^4. If you update a VI from version 5 to version 6i, this is automatically done, but if you're programming in 6i, you'll need to use that syntax for your equations.

Mark
0 Kudos
Message 4 of 8
(4,422 Views)
Thanks fellas for those responses. The equation I had in my vi did not
have that '^' error, that was a typo. I tried all sorts of different
formats like you suggested and I tried simpler equations etc. Still
nothing.

Darren I'd really like to show you the vi if you wouldn't mind. How do
I attach files on the newsgroup?

Thanks again
0 Kudos
Message 5 of 8
(4,422 Views)
oh, yeah, make sure that you have a semicolon ";" at the end of your equation.

Mark
0 Kudos
Message 6 of 8
(4,422 Views)
Kieran,

Make sure you follow the suggestions of the others in the group and use the new '**' syntax for powers (instead of the old '^' syntax). Also make sure to put a semicolon on the end of your statement, as was also suggested. If neither of these suggestions helps, you can reply to your original post and you will have the ability to attach a file with the "Attach Files" button underneath the message.

I'm hoping though, that the '**' or semicolon suggestions do the trick.

Good luck,
Darren
0 Kudos
Message 7 of 8
(4,421 Views)
It might have to do with the capital letters in your formula. The online help for the Parse Formula String VI has a list of acceptable variables. They are:

"a, a0,...,a9

b, b0,...,b9

.

.

.

z, z0,...,z9

Note: For variable and function names, only lowercase letters are allowed. The VIs interpret capital letters as errors."

Giv that a try.
0 Kudos
Message 8 of 8
(4,421 Views)