How to run an if statement in a cell?

2 ビュー (過去 30 日間)
Daniel Tanner
Daniel Tanner 2019 年 8 月 5 日
コメント済み: Stephen23 2019 年 8 月 7 日
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 件のコメント
Alex Mcaulley
Alex Mcaulley 2019 年 8 月 5 日
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 2019 年 8 月 5 日
Yes that would be the output I would want.

サインインしてコメントする。

採用された回答

Alex Mcaulley
Alex Mcaulley 2019 年 8 月 5 日
編集済み: Alex Mcaulley 2019 年 8 月 5 日
A possible soution:
sol = cellfun(@(in) in > 0.1*mean(in(:)),A,'uni',0); %where A is your cell array
  7 件のコメント
Daniel Tanner
Daniel Tanner 2019 年 8 月 7 日
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 2019 年 8 月 7 日
"Do you know of a more simpler way to do this?"
Take a look at blockproc, histcount, histcounts2, etc..

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by