Как я понимаю, у вас есть:
N = 1000;
% an array with 0s and 1s (this generates random 0s and 1s):
conditionArray = randi([0,1],N);
% a cell array with strings (this generates random 5-character strings):
netNames = cell(N);
netNames = cellfun(@(c)char(randi([double('a'),double('z')],1,5)), netNames, 'UniformOutput',false);
Чтобы извлечь элементы из netNames
, где conditionArray
равно 1, вы можете сделать:
netNames(conditionArray==1)
Это использует логическое индексирование в массив ячеек.