【问题标题】:Append A Column To A Matrix Matlab将一列附加到矩阵 Matlab
【发布时间】:2014-11-12 03:07:33
【问题描述】:

我正在遍历矩阵中的每一列并对该列中的每个元素执行操作。问题是,如何将此列添加到另一个矩阵的末尾?

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

【问题讨论】:

    标签: matlab matrix append


    【解决方案1】:

    您可以像这样附加列:

    normalized_features = [normalized_features cur_col];
    

    此操作水平连接两个矩阵。有关详细信息,请参阅 Matrices and Arrays 文档。

    【讨论】:

    • 这似乎可行,谢谢!你介意解释你的答案吗? (附:我昨天刚开始使用matlab)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-10-21
    • 1970-01-01
    • 1970-01-01
    • 2016-11-11
    • 2016-02-29
    • 2016-11-14
    • 2015-10-06
    相关资源
    最近更新 更多