Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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);

Respuesta aceptada

Guillaume
Guillaume el 13 de Nov. de 2014
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.
  2 comentarios
Hana
Hana el 13 de Nov. de 2014
Thanks for the answer...If I want to subtract each Tb cells(only those which meet the condition) by me1,then how can I do the indexing?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by