MATLAB: Display all the intermediate results of a code

findpeaksstore all results

Dear MatLab users,
As beginner of MatLab, I am facing an issue that I cannot solve alone. I am using "findpeaks" as code to extract the number of peaks and the corresponding width (halfheight) of a data array. The code (very simple) is the following:
importdata('...\data.dat');
x=ans(:,1);
for i=[2:47]
[pks,locs,widths,proms] = findpeaks(ans(:,i),x,'MinPeakProminence',40,'Annotate','extents','WidthReference','halfheight');
widths
end
However the code only stores the last result (width), while I would like that the code stored all the results for each y coordinate, that is 'ans(:,i)'.
Any advise would be really helpful.
Thanks.
Paolo

Best Answer

Dear Walter,
thanks for your quick reply.
Unfortunately, the code does not work by showing the following message:
Unable to perform assignment because brace indexing is not supported for variables of this type.
Error in Peaks_TimeTrace_TIRF_new (line 3)
[pks{i},locs{i},widths{i},proms{i}] =
findpeaks(data(:,i+1),x,'MinPeakProminence',40,'Annotate','extents','WidthReference','halfheight ');
Thanks.
Paolo