simulataneous Curve fitting
2 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I am using matlab to fit a family of curves. I want to have one term in the curve with a different coeeficentfor each curve in the family.
For example say I have 3 curves. Then I want to have a term in my curve such that one of my curves has 1*a, the second curve has 2*a, and the third curve has 3*a where a is the same for all 3 curves
This would require matlab to find "a" simultaneously for all 3 curves and i was wondering how to do that in matlab. I have the curve fitting toolbox but it doesn;t seem to support this simultaneous fitting. Thank you.
3 件のコメント
Friedrich
2011 年 8 月 10 日
Could you give us a more specific example? Sounds like it can be achieved with MATLAB itself or maybe Curve Fitting Toolbox can help here.
採用された回答
Friedrich
2011 年 8 月 10 日
Hi,
EDIT again full post to match better:
%some x values
x = 1:0.1:10;
%some y values, normally you don't know how they are created, so add some
%noise
y_1 = log(x) + 1*3 + rand(size(x))/10;
y_2 = 2*log(x) + 2*3 + rand(size(x))/10;
y_3 = 0.5*log(x) + 3*3 + rand(size(x))/10;
% so looking for a fit like c_1*log(x) + 1*a for the first one, c_2*log(x) + 2*a for
% the second one and c_3*log(x)+ 3*a for the third one
%so 4 unknown c_1,c_2,c_3 and a which is the same for all the functions
X = [ log(x)', zeros(size(x))', zeros(size(x))', ones(size(x))' ;
zeros(size(x))', log(x)',zeros(size(x))', 2*ones(size(x))' ;
zeros(size(x))', zeros(size(x))', log(x)',3*ones(size(x))' ];
Y = [ y_1';
y_2';
y_3'];
out = X\Y;
%plot data
hold on
scatter(x,y_1,'*')
scatter(x,y_2,'+')
scatter(x,y_3,'o')
plot(x,out(1)*log(x) + out(4)*1,'b')
plot(x,out(2)*log(x) + out(4)*2,'g')
plot(x,out(3)*log(x) + out(4)*3,'r')
hold off
その他の回答 (1 件)
Fangjun Jiang
2011 年 8 月 10 日
Subtract your first curve with 1a, second curve with 2a and third curve with 3a and then do the curve fitting?
参考
カテゴリ
Help Center および File Exchange で Get Started with Curve Fitting Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!