Ana
Ana

Reputation: 15

peak finder for multidimensional array

I'm trying the following and is not working. Could someone help me on this?

A=rand(1,4,5);
peak_num=zeros(5,4);
for w=1:5
  peak_num(w,:)=peakfinder(A(1,1:4,w))
end
peak_num;  

in this case the vector of peaks found for each w has a different size.

Thanks

Upvotes: 0

Views: 151

Answers (1)

Matthias W.
Matthias W.

Reputation: 1077

I haven't really taken a look at the internals of the peakfinder function but if you make sure that it does not output a vector with more than 4 elements this is a workaround:

A=rand(1,4,5);
peak_num=zeros(5,4);
for w=1:5
    temp = peakfinder(A(1,1:4,w));
    peak_num(w, 1:length(temp) ) = temp
end
peak_num;  

It sets the first elements to the return values and keeps the others being zero.

Upvotes: 1

Related Questions