MATLAB: Random numbers and Matrix

matrixrandom number generatorsimulation

a=30;
b=3;
A=rand(a,b)<0.85;
B=zeros(30,1);
C=A;
D=[A B C]
This is what I am using now and would like to know how to make 0 and 1 matrix become 0's one by one. I am making a aircraft model and I am using 30*7 matrix to simulate people getting off the plane. Any suggests how to go about doing this?

Best Answer

Example:
col_order = [3 5 2 6 1 7];
seat_letters = 'ABCxDEF';
for K = 1 : length(col_order)
this_col = col_order(K);
left_in_col = reshape( find(D(:,this_col)), 1, []);
for row = left_in_col
D(row, this_col) = 0;
fprintf('Passenger in %d%c got off\n', row, seat_letters(this_col));
end
end
Related Question