I want to delete some cell(s) from cell array in Matalb on run time in nested for-loops, so that I want permanently delete cell and on next iteration, It will not consider that cell infect its next cell as its place, How I can perform this in Matlab, or any other suggestions to avoid cell array in this case. My cell array M contains objects information and P is the position values.
My Code:
for ii=1:1000
for jj=1:20
M{jj}=P{jj}(ii,:);
if (P{jj}(ii,:) ~= 0)
%here I want to delete M(jj) or M{jj} and also P(jj) or P{jj}
% My try M(jj) = []; M= M(~cellfun('isempty',M));
%but it gives error when the next iteration starts.
end
end
end
if (M{jj} == 0 )because the way you are assigningM{jj}before the conditional statements. - Divakarjjlikejj=2in this case. - user3593525