How can I do the average difference of two dataset?
조회 수: 5 (최근 30일)
이전 댓글 표시
for date = 1:436
for band = [1 2 3 4 5 7]
L2= L2_p181r040(date).SREF(band).Sur_Ref_L2_MASK;
SM = SM_p181r040(date).SREF(band).Sur_Ref_Mask_Normalized;
if isequal(size(L2),size(SM))
Diffs(date).AbsDiff(band).Ref_Diff = mean(SM-L2);
Band_DIFFs(band).diff(date) = Diffs(date).AbsDiff(band).Ref_Diff;
end
end
end
Hello all, I am getting error - Index exceeds the number of array elements (0).
For some of the dates, I don't have data for L2 variable but have all the dates for SM. I want to calculate the average difference between the two dataset (SM & L2), for only the dates which L2 have, so can you please help in this.
댓글 수: 0
채택된 답변
Voss
2022년 5월 6일
for date = 1:numel(L2_p181r040)
% skip L2_p181r040(date) if L2_p181r040(date).SREF is empty
if isempty(L2_p181r040(date).SREF)
continue
end
% otherwise do the thing
for band = [1 2 3 4 5 7]
L2 = L2_p181r040(date).SREF(band).Sur_Ref_L2_MASK;
SM = SM_p181r040(date).SREF(band).Sur_Ref_Mask_Normalized;
if isequal(size(L2),size(SM))
Diffs(date).AbsDiff(band).Ref_Diff = mean(SM-L2);
Band_DIFFs(band).diff(date) = Diffs(date).AbsDiff(band).Ref_Diff;
end
end
end
댓글 수: 6
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!