%data matrix manipulation demo
%what you are trying to do is take the transpose of each given data
%and input them in sequential order into a data matrix
clc
fprintf('original data in matrix form looks like: \n');
%suppose your data looks like this
train0 = [1 6; 6 7; 7 2; 4 3; 2 4]
train9 = [3 4; 4 5; 8 3]
fprintf('size of train0 and train9: \n');
size(train0), size(train9)
fprintf('transpose of train0 and train9 \n');
train0 = train0' % set train0 to transpose of itself
train9 = train9' % ditto for train9
fprintf('size of transposed train0 and train9 \n');
[m0, n0] = size(train0);
[m9, n9] = size(train9);
size(train0)
size(train9)
% number of features = 2 for both train0 and train9
% here m0 = 2 = #feats of train0
% and m9 = #feats of train9
% train0 has 5 data examples i.e. n0 = 5
% train9 has 3 data examples i.e. n9 = 3
% we want to create a data matrix called: data
% where data is size 3x(5+3) the last row of the matrix should contain the
% labels for the data
% here we will use label = 1 for train0
% and we will use label = 0 for train9
% then the first 5 columns of data is train0 and the last 3 are train9
data = zeros(3,n0+n9); %create data matrxix of the size we want
% input train0 data and labels as first n0 columns of data matrix
fprintf('data matrix after adding train0 to it: \n');
data(1:2,1:n0) = train0 % <--input train0 data into matrix
pause(1)
fprintf('data matrix after adding labels of train0 to it: \n');
data(3,1:n0) = 1 % input label for train0 into the matrix
pause(1)
%input train9 data and labels as last n9 columns of data matrix
fprintf('data matrix after adding train9 to it: \n');
data(1:2,1+n0:n0+n9) = train9 % <--input train9 data into matrix
pause(1)
fprintf('data matrix after adding labels of train9 to it: \n');
data(3,1+n0:n0+n9) = 0 % input label for train9 into the matrix
fprintf('final data matrix is: \n');
data
% save data matrix as data_train_0vs9.mat
save data_train_0vs9.mat data
% to load data, simply type: load data_train_0vs9.mat
% in your script and data will be loaded into the console
% you can try it by typing: clear all
% then type: load data_train_0vs9.mat
% type: data
% and you will see that it is loaded