Reputation: 251
I am iterating through each column in a matrix and performing an operation on each element in that column. Problem is, how do I add this column to the end of another matrix?
normalized_features = [];
for col = 1:6;
cur_col = features(:, col);
for i = 1:length(cur_col);
elm = cur_col(i);
elm = (elm - features_mean(col)) / features_standard_dev(col);
cur_col(i) = elm;
if i == length(cur_col)
% append cur_col to normalized_features matrix
end
end
end
Upvotes: 0
Views: 745
Reputation: 2276
You can append the column like this:
normalized_features = [normalized_features cur_col];
This operation concatenates the two matrices horizontally. See the Matrices and Arrays documentation for more information.
Upvotes: 2