04-08-2010 09:23 AM
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.
04-08-2010 11:53 PM
Hi,
Which version of LabVIEW do you use? I try your code in both LabVIEW 8.6 and 2009. Everything works well.
04-09-2010 02:03 AM