simulataneous Curve fitting

조회 수: 3 (최근 30일)
Syd
Syd 2011년 8월 10일
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
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.
Syd
Syd 2011년 8월 10일
basically the curves that I am using have a known relationship to me. They all differ by a distance of 1(I know I haven't explained what this distance represents but don;t think that will affect anything). I want to force this relationship to show up in the curves so that each curve has a term whose coeeficent is representative of its distance

댓글을 달려면 로그인하십시오.

채택된 답변

Friedrich
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
  댓글 수: 4
Syd
Syd 2011년 8월 11일
thanks again!!
Syd
Syd 2011년 8월 11일
also, I've added a follow up if u get a chance to look at it http://mathworks.com/matlabcentral/answers/13527-simulataneous-curve-fitting-follow-up thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Fangjun Jiang
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?
  댓글 수: 1
Syd
Syd 2011년 8월 11일
could you explain a little more? thanks so much!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile 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!

Translated by