How to shift a matrix by a specified number of points

4 次查看(过去 30 天)
I am looking to align the highest peaks of two sets of 2500x1 matrix data to the same point number. My program obtains the sample number associated the highest amplitude peak of each data set and I can get the difference in data points between the two peaks. I need to either shift one of the data sets by the difference in data points or add zeros to one of the data points so that they align. Does anyone know how this can be done? Thank you

回答(1 个)

dpb
dpb 2016-5-22
编辑:dpb 2016-5-22
'Pends on what you want to happen w/ the rest of the data...it's trivial enough to simply augment a vector with zeros on either end but you might want to read
doc circshift
ADDENDUM
Well, if you have the two points of interest, then pick one as the reference; I'll presume to move the one with the rightmost peak and, for convenience in addressing the two that they're in a 2D array by column.
Given then nChMax is the corresponding 2-vector of the locations, to align the two would be
[~,idx]=max(nChMax); % determine which is the rightmost peak of the two
nZ=abs(diff(nChMax)); % the offset between the two in absolute mag
s(:,idx)=[s(nChMx(idx)-nZ:end,idx); zeros(nZ,1)]); % shift up by nZ and augment
This "throws away" the first of the shifted signal maintaining the same overall length. Alternatively, you can also augment the other with nZ at the front and keep the full length of signal but other than for visual purposes it won't matter as there's nothing matching when you get ready to do the calculations on a pointwise basis.
  1 个评论
Aoife Monahan
Aoife Monahan 2016-5-22
I'm looking to get the attenuation coefficient using two sets of ultrasound data. I need to be able to get a power spectrum on both sets and then divide the spectra to calculate the attenuation coefficient. How would you add zeros onto the beginning or end?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by