MATLAB Answers

Spectral or peak alignment

66 views (last 30 days)
Hello: I have two spectra, Spectrum A and Spectrum B. Spectrum A is the reference spectrum and spectrum B is one I just collected. I'm trying to match spectrum B with the reference spectrum A. However, I realized that the peaks in B are a bit shifted.
My question is how do I correctly align B to the reference A using matlab?
How do I correct for the peak shifts in my spectrum so that they align correctly to the reference spectrum using matlab or any other program or algorithm?
Thank you.


dpb on 9 Jul 2017
'Pends on what kind of shift you're talking it simply a phase shift of the whole spectrum or a shrinkage/expansion?
Attach at least figure; data would be better...
Curious Mind
Curious Mind on 9 Jul 2017
I just attached a figure. Thank you.

Sign in to comment.

Accepted Answer

Kateryna Artyushkova
Kateryna Artyushkova on 19 Oct 2018
Maybe this will work:


Sign in to comment.

More Answers (2)

Star Strider
Star Strider on 9 Jul 2017
One option is to use the Signal Processing Toolbox alignsignals (link) function. That is not its intended use, but it could work. (It is relatively recent. The documentation does not say when it was introduced.)


dpb on 10 Jul 2017
What kind of spectroscopy of what sample?
In gamma spec, a slight energy calibration difference will shorten/lengthen on reference spectrum vis a vis another. An alignment there by a linear ratio vs channel will bring the two in line but it is linear by the gain difference. A truly nonlinear response wouldn't occur that way.
Curious Mind
Curious Mind on 10 Jul 2017
@Image Analyst:
I really appreciate the information. I think I'm gonna leave the data the way it is. Thank you so much.
Curious Mind
Curious Mind on 10 Jul 2017
@dpb Thank you.

Sign in to comment.

Image Analyst
Image Analyst on 9 Jul 2017
Look up xcorr in the help and see this entry "Find a Signal in a Measurement". It says "You receive some data and would like to know if it matches a longer stream you have measured. Cross-correlation allows you to make that determination, even when the data are corrupted by noise."
and then it gives an example. Try it.

  1 Comment

Curious Mind
Curious Mind on 9 Jul 2017
Will do. Thanks very much.

Sign in to comment.

Sign in to answer this question.

Translated by