How to define a for loop for given FINDPEAKS problem ?
1 次查看(过去 30 天)
显示 更早的评论
[A1,L] = findpeaks(A(:,1));
A1(:,2) = A(L,2);
[A2,L1] = findpeaks(A1(:,1));
A2(:,2) = A1(L1,2);
[A3,L2] = findpeaks(A2(:,1));
A3(:,2) = A2(L2,2);
2 个评论
采纳的回答
Dyuman Joshi
2024-2-24
Try this -
n=3;
B = [num2cell(A,1); cell(n,2)]
for k=2:n
[B{k,1}, L] = findpeaks(B{k-1,1});
B{k,2} = B{k-1,2}(L);
end
Here 1st row of B corresponds to A, 2nd to A1, 3rd to A2 and 4th to A3.
Use indexing to access the data.
7 个评论
Dyuman Joshi
2024-2-29
Ah, that's a typo. My bad.
To correct it, replace
num = numel(d);
with
num = numel(data);
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!