if statement with multiple conditions within cells
Show older comments
Hello ,
I have two 75x1 cells called goodcase and badcase , each cell is composed by 75 logical vectors of the same size (241200 elements).
I want to find if the following case exists between the 2 cells:
one of the first 1200 elements of the logical vector in badcase is equal to 1 ,(let's call this element u) and one of the elements placed in the position u+1*1200 or the position u+2*1200 or u+3*1200 or u+4*1200 and so on until the highlighted numbers equal to 200 in the logical vector in goodcase is also equal to 1
I want to know the values of u and the values of the highlighted numbers that accomplish this case.
I tried with this code but It does not give me any result even when I have checked "by hand" that the case exists.
cases3=cell(75,1);%preallocating size of the statement
for gcellid=1:numel(goodcase)
cases3{gcellid}=zeros(1200,201);
end
for gcellid=1:numel(goodcase);
ii=1:numel(1200);
for y=1:200;
if badcase{gcellid}(ii)==1 & goodcase{gcellid}(ii+y*1200)==1;
cases3{gcellid}(ii,y)=1
end
end
end
PP3=cellfun(@(x) find(x(:,:)==1),cases3,'un',false)%linear position of the cases I want
Accepted Answer
More Answers (0)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!