I have a sparse matrix in MATLAB:
N=1000;
P=0.01;
A=sprand(N,N,P);
and I want to change all non zero entries at certain columns into ones.
That is, something like this:
c=randi(N,[1,round(N/10)]);
A(non zeros at columns c)=1;
Of course it can be done in a for loop, but that's clearly not the solution I'm looking for. I tried several solutions using nnz, nonzeros, spfun - but with no soccess. Can anyone come up with a simple way to do it?
Thanks, Elad