collect ten matrix 784x1 and store it like 784x10 in matlab

One way to collect ten matrices of size 784x1 and store them in a single matrix of size 784x10 in MATLAB is by using a loop along with indexing.

main.m
% Initialize the matrix to store ten 784x1 matrices
matrix_collection = zeros(784, 10);

% Loop through each of the ten matrices
for i = 1:10
    % Generate each 784x1 matrix
    matrix = rand(784,1);
    % Store the matrix in the collection matrix
    matrix_collection(:,i) = matrix;
end
290 chars
11 lines

In this example, we first initialize the matrix_collection to a matrix of zeroes with dimensions 784x10. We then loop through each of the ten matrices that we want to collect, generating each 784x1 matrix using rand() function. Finally, we store each generated matrix in the collection matrix using (:,i) indexing.

At the end of the loop, matrix_collection would contain ten 784x1 matrices stored as columns.

gistlibby LogSnag