From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use "lsqcurvefit" in labview 8.6

I learn to use 'lsqcurvefit'  function by the example in labview 8.6 help,

first, define myfum.m as follows:

function [F, df] = myfun(a, xdata)
F = a(1)*xdata.^2 + a(2)*cos(xdata);
df = zeros(0, 0);

then I use a mathscript node in block diagram,define as follows:

a = [2, 1.5];
x = 0:1:19;
noise = randn(size(x)) / 5;
y = a(1)*x.^2 + a(2)*cos(x) + noise;
[x, normres, resid] = lsqcurvefit('myfun', [10, 10], x, y);

however, when I run the program,labview always tell me:

Error -90111 occurred at Error in function lsqcurvefit line 5.The function you

specified as an argument is invalid.

 

Who tell me why?thanks. 

0 Kudos
Message 1 of 3
(6,612 Views)

Hi,

 

Which version of LabVIEW do you use? I try your code in both LabVIEW 8.6 and 2009. Everything works well.

 

0 Kudos
Message 2 of 3
(6,607 Views)
thanks, the problem is solved, the error due to the path of myfun.m.My labview version is 8.6
0 Kudos
Message 3 of 3
(6,605 Views)