フィルターのクリア

I'm trying to use the findpeaks function in a for-loop for a large array and struggling to generate multiple outputs

5 ビュー (過去 30 日間)
Hello all,
I'm super new to matlab and have a (hopefully) basic question. I have a 23 row array and a predetermined threshold and I'm trying to evaluate the peaks per row. I, unfortunately, am only able to generate one output instead of 23 currently. I have the beginnings of some code below for array "dff"
for i=1:size(dff, 1)
[pks,locs]=findpeaks(dff(i,:), 2, 'MinPeakHeight', threshold(i));
end
In a perfect world I would have a 2 arrays at the end of this called "pksdata" and "locsdata" that would have 23 rows of information each. I apologize if this is an annoying question!

採用された回答

Mario Malic
Mario Malic 2023 年 9 月 12 日
編集済み: Mario Malic 2023 年 9 月 12 日
Hey,
If I understood correctly your question, you should use a cell array due to numeric array limitations which is that numeric array has to have equal number of columns in the same row and vice versa. Iit is not possible to do it with a numeric array because there might be different number of peaks in each row. You can squeeze your peaks and locations into a single element of cell array for each row like shown below.
pks = cell(size(dff, 1), 1);
locs = cell(size(dff, 1), 1);
for i=1:size(dff, 1)
[pks{i},locs{i}]=findpeaks(dff(i,:), 2, 'MinPeakHeight', threshold(i));
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by