我正在迭代矩阵中的每一列,并对该列中的每个元素执行操作。问题是,如何将此列添加到另一个矩阵的末尾?
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
答案 0 :(得分:2)
您可以像这样添加列:
normalized_features = [normalized_features cur_col];
此操作水平连接两个矩阵。有关详细信息,请参阅Matrices and Arrays文档。