How to run an if statement in a cell?

2 visualizaciones (últimos 30 días)
Daniel Tanner
Daniel Tanner el 5 de Ag. de 2019
Comentada: Stephen23 el 7 de Ag. de 2019
I have a cell containting 125 by 125 elements where each element contains a local 36 by 36 array of data. I am new to this sort of work and I am currently carrying out some data analysis. I want to be able to determine if any of the local data (so data within the 36 by 36 array) are greater than 10% of the local average, but this needs to be done for the whole cell. I can carry this procedure out separately but this is not efficient. Am I correct that an 'if' statement would be able to get the job done? Any help on this would be greatly appreciated.
  2 comentarios
Alex Mcaulley
Alex Mcaulley el 5 de Ag. de 2019
Probably cellfun will help you.
What do you want exactly as output? A logical 36x36 array for each cell determining which element is greater than the 10% of the mean of the 36x36 elements?
Daniel Tanner
Daniel Tanner el 5 de Ag. de 2019
Yes that would be the output I would want.

Iniciar sesión para comentar.

Respuesta aceptada

Alex Mcaulley
Alex Mcaulley el 5 de Ag. de 2019
Editada: Alex Mcaulley el 5 de Ag. de 2019
A possible soution:
sol = cellfun(@(in) in > 0.1*mean(in(:)),A,'uni',0); %where A is your cell array
  7 comentarios
Daniel Tanner
Daniel Tanner el 7 de Ag. de 2019
Thank you.
Finally, and I understand this may not be possible. But what I am essentially doing is treating the original data set as pixels. So every point of data is a pixel that has detected a photon on a detector screen. I initially had a 4500 by 4500 array which I managed to split into a 125 by 125 cell with each element containg 36 by 36 pixels thanks to your help. I am looking at finding the number of defected pixels on the whole device (a defected pixel is one with a signal level >10% away from the mean either side, so < 0.9*mean and >1.1*mean are defined as defected pixels). Using your help I have managed to find the number of defected elements, and in them I have found the locations of the defected pixels and added them up, but that section is hard coded and can be tedious.
I wondered if there was a way to count all the defected pixels using code instead of counting all the defected areas myself. For example, here is the code I used to find the defected pixels for one of the data sets:
L900 = cellfun(@(in) in > 0.9*mean(in(:)) & in < 1.1*mean(in(:)),PRNU900_Cell,'uni',0);
DeflectedPixelsTest = sum(length(find(L900{123,2}>0))+length(find(L900{78,13}>0))+length(find(L900{31,17}>0))+length(find(L900{4,24}>0))+length(find(L900{93,24}>0))+length(find(L900{22,25}>0))+length(find(L900{23,25}>0))+length(find(L900{11,39}>0))+length(find(L900{92,41}>0))+length(find(L900{120,43}>0))+length(find(L900{62,53}>0))+length(find(L900{76,65}>0))+length(find(L900{103,69}>0))+length(find(L900{11,79}>0))+length(find(L900{32,84}>0))+length(find(L900{106,114}>0))+length(find(L900{107,114}>0))+length(find(L900{55,117}>0))+length(find(L900{81,119}>0)));
So as you can see, there were 19 defected regions in the whole of my L900 cell and I located them and counted the number of defected pixels within each of them.
Do you know of a more simpler way to do this? Sorry if this was confusing, let me know if anything needs clearing up. Thanks!
Stephen23
Stephen23 el 7 de Ag. de 2019
"Do you know of a more simpler way to do this?"
Take a look at blockproc, histcount, histcounts2, etc..

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays 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