- nanmedian is in the statistical toolbox
- see NaN Suite by Jan Gläscher
Finding nanmedian of a 3D array.
조회 수: 5 (최근 30일)
이전 댓글 표시
Hi I have a 3D array and I am trying find the median with nans excluded. I used the nanmedian function but i get the error 'Unexpected MATLAB expression'for the line I have commented out. Could you tell me why? How can i make it right?
for i=1:size(tempBeforeDelam,1)
%
for j=1:size(tempBeforeDelam,2)
%
if(abs((tempBeforeDelam(i,j,1)-tempBeforeDelam(i,j,2)))< 1 && abs((tempBeforeDelam(i,j,2)-tempBeforeDelam(i,j,3))) < 1 && abs((tempBeforeDelam(i,j,3)-tempBeforeDelam(i,j,4))) < 1 && abs((tempBeforeDelam(i,j,4)-tempBeforeDelam(i,j,5))) < 1 && abs((tempBeforeDelam(i,j,5)-tempBeforeDelam(i,j,1))) < 1)
%
% beforeDelam(m,n)= nanmedian[tempBeforeDelam(i,j,1) tempBeforeDelam(i,j,2) tempBeforeDelam(i,j,3) tempBeforeDelam(i,j,4) tempBeforeDelam(i,j,5)]
%
end
end
end
댓글 수: 1
per isakson
2015년 6월 9일
편집: per isakson
2015년 6월 9일
채택된 답변
Sean de Wolski
2015년 6월 9일
You have brackets [] instead of parenthesis ()
This should do it; you can use 1:5 and take nanmedian along third dimension to avoid unrolling the pieces:
beforeDelam(m,n)= nanmedian(tempBeforeDelam(i,j,1:5),3)
Also note that in 15a, median now has an 'omitnan' flag so you can use it instead.
median(tempBeforeDelam(i,j,1:5),3,'omitnan')
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!