linear combination of curves to match a single curve
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have measured 3 different data sets with the same amount of x variables. Two of these data sets are reference materials (called ref1 and ref2). Now I want to write a routine in matlab to fit the third data set by varying the weight of the two other data sets to get an idea of the contribution of ref1 and ref2 to the third signal, like:
y=w1*ref1+w2*ref2
in some cases there is one boundary condition that w1+w2=1
Is it possible to get a rough idea about the error of w1 and w2?
0 Kommentare
Antworten (1)
dbmn
am 20 Feb. 2017
This can be done nicely in a least squares approach - especially with Matlab mldivide operator.
I will give you an example
% Generate Test Data
x1 = rand(10,1);
x2 = rand(10,1);
y = x1 + 2*x2;
% Solve for w1 and w2
w = [x1 x2]\y
If you have additional conditions such as w2 = 1 - w1 (x1+x2=1) just add those to your equation and solve
f.ex. y = w1*x1 + w2*x with w2 = 1 - w1
y = w1x1 +(1-w1)x2
y - x2 = y_hat = w1 x_hat = w1 (x1-x2)
And then use the first solution
0 Kommentare
Siehe auch
Kategorien
Mehr zu Linear and Nonlinear Regression 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!