Im converting a code from python to Matlab
C = np.arange(old_dim)
R = np.random.random_integers(ksq, size=old_dim) - 1
D = np.random.randint(2, size=old_dim) * 2 - 1
S = scipy.sparse.csr_matrix((D, (R, C)), shape=(ksq, old_dim))
The Matlab code i wrote.
R = randi(ksq,[1,old_dim]) - 1;
D = randi(2, [1,old_dim]) * 2 - 1;
S = sparse(R,C,D,ksq,old_dim);
When i run my matlab code, it tells me
Error using sparse Index into matrix must be positive.
My guess is when i have a zero in one of the variables R C D thats when it throws this error? and what could be a solution to this. thanks