How to manipulate cell array values of arrays with different lengths?

조회 수: 3 (최근 30일)
I have a cell array of peaks from a dataset matrix that is 5119x102 called CH1WaveForm_1. I have found the peaks for certain values within the matrix that have a value greater than 10 as seen in the code below.
for i=1:size(CH1WaveForm_1,2)
[timePks{i},timeLocs{i}]=findpeaks(CH1WaveForm_1(1200:1450,i));
for k=1:length(timePks)
newCell{k}=timePks{k}(timePks{k}>10);
end
end
My newCell{k} is 1x102 and each cell has a different array length as seen in the picture below.
I want to create a new vector that gives the ratio of the first row divided by the second row for each cell array. If there is no value/only one value in the cell array then I want the value to be equal to zero in this new vector.

채택된 답변

David Hill
David Hill 2020년 6월 16일
for k=1:length(newCell)
if numel(newCell{k})<2
m(k)=0;
else
m(k)=newCell{k}(1)/newCell{k}(2);
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by