My cell array has 861 rows and each row has vectors of varying sizes. I want to calculate std dev only for cells that have 20 elements. Others should give a value of 0. How do I tell cellfun to get only the cells with 20 elements. Here is my attempt
조회 수: 1 (최근 30일)
이전 댓글 표시
Stds=cellfun(@std ,ratios,'UniformOutput',false); % trying to calculate standard dev for cells for cell array 'ratios' that have 20 elements. All other cells should give 0.
댓글 수: 0
채택된 답변
the cyclist
2018년 5월 22일
편집: the cyclist
2018년 5월 22일
ratios = {rand(19,1); rand(20,1); rand(21,1)}
cellfun(@(x)std(x)*(numel(x)==20),ratios)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!