How to manipulate cell array values of arrays with different lengths?
2 ビュー (過去 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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/317145/image.jpeg)
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.
0 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!