Using ALS algorithm for writing a code

조회 수: 53 (최근 30일)
Lasya Maganti
Lasya Maganti 2019년 4월 26일
이동: Star Strider 2025년 11월 4일
Is ALS algorithm supported by MATLAB R2019a. What is the best source of downloading the alogorithm and the reference to write the code for analysing spectral data?

답변 (1개)

Star Strider
Star Strider 2019년 4월 26일
I’ve not run this, so I have no experience with it. It’s the only MATLAB code for the algorithm that I could find.
The slightly corrected version of the function:
function z = baseline(y, lambda, p)
% Estimate baseline with asymmetric least squares
m = length(y);
D = diff(speye(m), 2);w = ones(m, 1);
for it = 1:10
W = spdiags(w, 0, m, m);
C = chol(W + lambda * D' * D);
z = C \ (C' \ (w .* y));
w = p * (y > z) + (1 - p) * (y < z);
end
Also consider:
function z = baseline(y, lambda, p)
% Estimate baseline with asymmetric least squares
m = length(y);
D = diff(speye(m), 2);w = ones(m, 1);
for it = 1:10
W = spdiags(w, 0, m, m);
C = chol(W + lambda * (D' * D));
z = C \ (C' \ (w .* y));
w = p * (y > z) + (1 - p) * (y < z);
end
The documentation for the function is in the paper.
Experiment to get the result you want.
  댓글 수: 5
Raimund
Raimund 2025년 11월 4일
이동: Star Strider 2025년 11월 4일
Hi,
thanks. This implementation works great.
Best regards,
Raimund
Star Strider
Star Strider 2025년 11월 4일
이동: Star Strider 2025년 11월 4일
My pleasure!
A Vote would be appreciated!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Smoothing and Denoising에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by