Borrar filtros
Borrar filtros

linear combination of curves to match a single curve

8 visualizaciones (últimos 30 días)
katja henzler
katja henzler el 20 de Feb. de 2017
Respondida: dbmn el 20 de Feb. de 2017
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?

Respuestas (1)

dbmn
dbmn el 20 de Feb. de 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

Categorías

Más información sobre Linear and Nonlinear Regression en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by