How to fit multiple data sets?
2 ビュー (過去 30 日間)
古いコメントを表示
Dear all, I have the following question: I need to determine some coefficients(A,B,C,D,E):
ydata=[1:1:10];
xdata=[0.1:0.1:1];
zdata=[10:10:100];
Y=[A+B*X+C*X^2+D*X^3]*Z^E;
the code look as:
xx=xdata'; % X
yy=ydata'; % Y
zz=zdata'; % Z
vect_ones=(10,1);
%declare function
functionfit=@(x,a)x(1)*vect_ones+x(2)*a(1,:)+x(3)*power(a(1,:),2)+x(4)*power(a(1,:),3))*power(b(1,:),x(5));
initial values;
x0=[1 1 1 1 1]; % how arbitrary should be this value?
[x] = lsqcurvefit(functionfit,x0,XX,ZZ,XX);
Questions:
Why "b" is not recognized as variable as "a" is? Can lsqcurvefit function really work with two (multiple) sets of data)?
Thank you
0 件のコメント
採用された回答
Matt J
2013 年 6 月 17 日
編集済み: Matt J
2013 年 6 月 17 日
Why "b" is not recognized as variable as "a" is?
Because you didn't designate it as a variable. You only designated x and a
functionfit=@(x,a)...
That's the way Anonymous Functions work.
Can lsqcurvefit function really work with two (multiple) sets of data)?
It's not clear what you mean by multiple sets of data. As long as ydata has the same dimensions as the output of functionfit, it should be fine.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!