필터 지우기
필터 지우기

Align signals of different length using Peak

조회 수: 13 (최근 30일)
Ganesh Naik
Ganesh Naik 2022년 7월 7일
댓글: Ganesh Naik 2022년 7월 7일
Hi all, I have set of signals of varying length stored in a cell array. I would like to align them based on their peaks. I have tried using matlab function "alignsignals" as well but no luck with it due to the varying datasize. I have added the data and my effort below. Any help in this regard is highly appreciated.
figure();
hold on;
for i = 1:length(my_arrays)
T = (my_arrays{i});
[Pks,Locs] = findpeaks(T,'MinPeakHeight',100)
plot(T);
end
Another effort (gives error due to varying datalength)
[r,c] = size(my_arrays)
disp(my_arrays);
for i = 2:c
Aligned_curves(:, i-1) = alignsignals(my_arrays{1:r, i-1}, my_arrays{1:r, i}, []);
end
figure;
plot(Aligned_curves);

답변 (1개)

KSSV
KSSV 2022년 7월 7일
편집: KSSV 2022년 7월 7일
According to the plot, the peak value which has longest id is third array. So, I would allign signals w.r.t to third array.
load('my_arrays.mat') ;
N = length(my_arrays) ;
% Get maximum and id of each signal
val = zeros(N,1) ;
id = zeros(N,1) ;
for i = 1:N
[val(i),id(i)] = max(my_arrays{i}) ;
end
% Get the id of signals which has longest maximum id
[~,T] = max(id) ;
X = my_arrays{T} ;
Y = cell(N-1,1) ;
figure();
hold on;
plot(X)
for i = 1:length(my_arrays)-1
if i~=T
[~,Y{i}] = alignsignals(X,my_arrays{i}) ;
plot(Y{i});
end
end
Y{T} = X ;
  댓글 수: 3
KSSV
KSSV 2022년 7월 7일
Yes that can be done. I have edited the code, so that T = 3, is automatically picked up.
You may have a look on id to see what do I mean longest max index.
Ganesh Naik
Ganesh Naik 2022년 7월 7일
Dear KSSV thanks, I am going to accept this answer. Since the data is of varying length is it possible to compute average of data (ensemble average) and plot the average data as a thick line in the plot?
Kind regards

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

카테고리

Help CenterFile Exchange에서 Get Started with Signal Processing Toolbox에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by