Я пытаюсь создать матрицу с записями от -1 до 1 и 10%, 20%, ..., 90% нулей в matlab.Пока что у меня есть
numRows = 100; % Number of Rows
numCols = 2*numRows; % Number of Columns
percentageZeros = 0.1 : 0.1 : 0.9; % Percentage of Zeros (options)
for currPercentageZeros = percentageZeros
do
A = zeros(numRows, numCols); % Initialize matrix
for row = 1:numRows
for col = 1:numCols
rnd = rand;
if rnd > currPercentageZeros
A(row, col) = 2*rand-1;
endif
endfor
endfor
until (rank(A) == numRows)
, но это не совсем точно.Кто-нибудь знает лучшее решение?