How Can I Remove Some Entries In A Matrix. I Am Converting From Matlab To Python
Here is a matlab code i would like to convert m=100; n=100 idx_MV = randperm(m*n); Q = ones(n, m); Q(idx_MV(1:round(MV*m*n))) = 0; can i get a python equivalent of this piec
Solution 1:
Maybe, you could try it :
import numpy as np
q = np.ones((2, 1))
q[your_index_function(args)] = 0
and your_index_function(args)
must return a same shape array as q
with boolean values according to your conditions (like idx_MV
behavior?)
Post a Comment for "How Can I Remove Some Entries In A Matrix. I Am Converting From Matlab To Python"