필터 지우기
필터 지우기

problems in loop with findpeaks

조회 수: 1 (최근 30일)
maria
maria 2012년 4월 1일
Hi, I am having problems in a loop with the function "findpeaks.m". I think the solution is very simple, but I cannot find it.
My code is:
A=[1 2 3 1 2; 1 15 2 5 2;1 2 1 2 1];
[x y]=size(A);
a=zeros(x,5);
for i=1:1:x;
a(i)=findpeaks(A(i,:));
end
The problem is findpeaks function give me vectors with different size. Could someone help me? Thanks in advance.

채택된 답변

Wayne King
Wayne King 2012년 4월 1일
Hi Maria, Because you cannot expect the number of peaks in the rows of A to be the same in each row, you can use a cell array to capture the number of peaks in each row.
A=[1 2 3 1 2; 1 15 2 5 2;1 2 1 2 1];
[x y]=size(A);
for i=1:x
a{i}=findpeaks(A(i,:));
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by