MATLAB: Second problem uitable

genetic algorithmuitable

i have another problem similarly with before:
m=3; d=5; b=num2cell(zeros(m,d)); b{1,1} = rand; b{1,6} = rand; b{2,7} = rand;
how can I save the 0 filled cells and random number filled cells differently?

Best Answer

  • iszero = cellfun(@(p) isequal(p,0),b);
    Now you can find(iszero) or find(~iszero) or use b(~iszero)