将数据存储在行矩阵中

时间:2014-07-02 10:12:19

标签: matlab

我有像这样的MATLAB程序

for m = 1:2

    %# Some code to calculate a matrix (Ytotale)
    %# Size of Ytotale is (1200 * 144) %%

    %#...

    Yfinal = Ytotale;

    for l = 1:1200
        i = l;

        j = retard(l,1);
        if Yfinal(i,j) == 0
            Yfinal(i,j:end) = circshift(Yfinal(i,j:end),[retard(l,2) retard(l,2)]);
            for j = retard(l,1):retard(l,1)+retard(l,2)-1
                Yfinal(i,j) = 1;
            end
        else
            Yfinal(i,j:end) = circshift(Yfinal(i,j:end),[retard(l,2) retard(l,2)]);
            for j = retard(l,1):retard(l,1)+retard(l,2)-1
                Yfinal(i,j) = 0;
            end
        end

    end

    %# ( Here i , j are index of matrix Ytotale , and l is the index 
    %# of matrix retard of size (1200 * 2) 

    for i =1:1200        
        not_char(i,1) = sum(Yfinal(i,1:144));        
        req(i,1) = sum(Ytotale(i,1:144));
    end

    final = req - not_char;    
    ve_delay = sum(Yfinal(:,1:144))';

end

整个过程将从m = 1 to 2迭代,并且将形成两个Ytotale矩阵,因此我想将ve_delay和final的值存储在每个{{1}的行矩阵中但是我的代码会覆盖矩阵值。

请帮忙......

1 个答案:

答案 0 :(得分:0)

此答案改编自macduf的评论

尝试final{m} = req - not_char;ve_delay{m} = sum(Yfinal(:,1:144));。这些值现在存储在单元格矩阵(大括号表示法)中。之后,您可以将单元格数组转换为常规数组。