# 2 unknowns in matching datasets

3 views (last 30 days)
Asliddin Komilov on 25 Apr 2022
Commented: Asliddin Komilov on 25 Apr 2022
Hello everyone.
I have 3 sets of data and need to find "a" and "b":
Y1=a*Y2+b*Y3;
there are 2 unknowns so I would need 2 equations to solve this but maybe there is a way to solve this as is? Help please.
Thank you

DGM on 25 Apr 2022
Edited: DGM on 25 Apr 2022
I'm sure there are other ways, but:
% omit nans
nanmask = ~(isnan(Y1) | isnan(Y2) | isnan(Y3));
% when overdefined, mldivide returns the least-squares solution
ab = [Y2 Y3]\Y1
ab = 2×1
0.7007 0.2259
That said, I'm not sure it's going to be good enough to just blindly process the data. Y1 doesn't look like the linear combination of Y2 and Y3 (at least it doesn't respond events in Y2).
Y1est = [Y2 Y3]*ab; % assume that Y1 is a linear combination
subplot(2,1,1)
plot(Y2); hold on
plot(Y3)
subplot(2,1,2)
plot(Y1); hold on
plot(Y1est)
Some sort of preprocessing is probably warranted here.
Asliddin Komilov on 25 Apr 2022
Sorry if I misled you anyhow.
It is not supposed to be linear, these are spectral distribution of light sources. The code should add the values for each wavelength (x-axis). And the power (integrals) of combined sources must me as close as possibe to the single one.
Later I may look for other light sources those's shapes also match better, but the main thing is that the code gives the correlation coeffients to match the combination of multiple sources with the etalon source.
Thanks