simulataneous Curve fitting

3 Ansichten (letzte 30 Tage)
Syd
Syd am 10 Aug. 2011
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 Kommentare
Friedrich
Friedrich am 10 Aug. 2011
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 am 10 Aug. 2011
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

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Friedrich
Friedrich am 10 Aug. 2011
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 Kommentare
Syd
Syd am 11 Aug. 2011
thanks again!!
Syd
Syd am 11 Aug. 2011
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!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Fangjun Jiang
Fangjun Jiang am 10 Aug. 2011
Subtract your first curve with 1a, second curve with 2a and third curve with 3a and then do the curve fitting?
  1 Kommentar
Syd
Syd am 11 Aug. 2011
could you explain a little more? thanks so much!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by