フィルターのクリア

linear combination of curves to match a single curve

8 ビュー (過去 30 日間)
katja henzler
katja henzler 2017 年 2 月 20 日
回答済み: dbmn 2017 年 2 月 20 日
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?

回答 (1 件)

dbmn
dbmn 2017 年 2 月 20 日
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

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by