MATLAB: Convert contents of array into index

arrayscolumnsmatrices

Hello,
I have an array. 1×3127 double which contains the indexes of another array. I want to use those index values to index another array and make those points =0
So for example,
col = [21 34 56 78 54 99];
l(col) = 0; % where l is another array for which I want l(21),l(34),l(56) = 0 etc.
I tried using the following code snippet but it does not work.
col = find(l<0);
for ii = 1:length(col)
a= cell2mat(ii);
l(a) = 0;
end
Please help! Thanks!

Best Answer

Your first code should work.
l = ones(1, 10000); % make sure this is bigger than the largest index col will specify
col = [21 34 56 78 54 99];
l(col) = 0; % this makes the 21st, 34th, 56th, etc. elements 0