I want to calculate the mean of the cells in 3 different images(T1,T2,T3),when the condition applies. each pair of R and T are overlapping and have the same size but T1,T2,T3 have different size

1 次查看(过去 30 天)
The cellfun function returns 3 diffrent mean valued for each array..I need a single mean value calculated from all the arrays.
t1=[1 2 3 ; 4 5 6 ; 7 8 9]; t2=[1 2 ;3 4]; t3=[2 3 4 5; 6 7 8 9];
R1=[10 11 10;13 14 12;16 18 12]; R2=[10 15;12 14]; R3=[10 13 17 18;16 14 12 10];
T = {t1,t2,t3}; R={R1,R2,R3};
me1 = cellfun(@(T, R) mean(T(R>=10 & R<12)), T, R); me2 = cellfun(@(T, R) mean(T(R>=12 & R<14)), T, R); me3 = cellfun(@(T, R) mean(T(R>=14 & R<18)), T, R);

采纳的回答

Guillaume
Guillaume 2014-11-13
You would have to concatenate your three filtered arrays before calculating the mean. E.G. for me1:
filtered1 = cellfun(@(T, R) T(R>= 10 & R<12), T, R, 'UniformOutput', false);
me1 = mean(vertcat(filtered{:}));
Same for me2 and me3.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by