Please help me in generating multiple matrices

1 visualización (últimos 30 días)
MANISH KUMAR
MANISH KUMAR el 27 de Jun. de 2016
Editada: Stephen23 el 27 de Jun. de 2016
this code is for one matrix X, but I want N = 5 such matrices
N = 5; % No. of matrices
P = 5; % The number of rows
T = 10; % The number of columns
% Duration of projects
D = [4; 5; 3; 2; 4];
excludedcount = D-1;
X = zeros(P,T);
for row = 1:P
rv = [1, zeros(1, T - excludedcount(row) - 1)];
X(row, 1 : (T - excludedcount(row))) = rv(randperm(numel(rv)));
end

Respuestas (1)

Walter Roberson
Walter Roberson el 27 de Jun. de 2016

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by