Linear Combination Analysis help

I have a spectrum (Stot) that's a linear combination of two known spectra (Sa and Sb). I would like to fit Stot , Stot = kSa + (1-k)Sb, and extract k and 1-k for Sa and Sb respectively from this fit. I have the Stot spectrum at a series of times, can I fit multiple spectra at one time?

回答(1 个)

One possibility:
k = 4.2; % Define ‘k’
t = linspace(1, 4*pi);
Sa = sin(t); % Create ‘spectra’
Sb = cos(t); % Create ‘spectra’
Stot = k*Sa + (1 - k)*Sb;
f = @(k) norm(Stot - (k*Sa + (1-k)*Sb)); % Cost Function: Nonlinear Approach
K = fminsearch(f, 2) % Estimate ‘k’: Nonlinear Approach
K = [Sa(:) Sb(:)]\Stot(:) % Estimate ‘k’: Linear Approach
However without your data I cannot claim that either of these will work reliably with it. Experiment to get the result you want.

类别

帮助中心File Exchange 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by