How to create array from old array with values greater than a specified value?

조회 수: 16 (최근 30일)
I have a cell array called timePks as seen below. Each cell has a column of numbers and I want to create a new cell array with the values from timePks that are greater than 20. I don't want the values that are less than 20 to be in the new cell array.
[timePks{i},timeLocs{i}]=findpeaks(aefm_1(1200:1450,i));
[ss{i},tt{i}] = find(timePks{i}>20);
When I run the code above, ss{i} gives me cell arrays of the row #'s that has a value above 20 but I want it to say the value, not the row number it belongs in.

채택된 답변

David Hill
David Hill 2020년 6월 15일
for k=1:length(timePks)
newCell{k}=timePks{k}(timePks{k}>20);
end
  댓글 수: 1
Kimberly Cardillo
Kimberly Cardillo 2020년 6월 15일
Thank you! I want to be able to say the first row is larger than the second row of each cell array. if true, then the value (labeled in a new vector) is equal to 1. How do I do that?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

the cyclist
the cyclist 2020년 6월 15일
% Some made-up data
timePks = {[10; 20; 30; 40],[5; 10; 20; 25],[1; 2; 3]};
% Output with only values greater than 20
output = cellfun(@(x)x(x>20),timePks,'UniformOutput',false)

카테고리

Help CenterFile Exchange에서 Geometry and Mesh에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by