【问题标题】:How to save different cube variables in matlab?如何在matlab中保存不同的立方体变量?
【发布时间】:2014-06-24 07:25:59
【问题描述】:

我有一个 for 循环,在每次迭代中它都会创建一个数据立方体,我想稍后在不同的 for 循环中使用它们。由于它们是立方体形式,因此不能像 a(:,j) 那样在每次迭代 j 中使用它们,就像我对向量一样。

有什么方法可以在循环结束后获得它们?使用num2str 怎么样?所以我有例如 a1, a2, ... ,我可以在下一个 for 循环中为 j 阅读它们吗(例如 a(j=1) )?

我有这样的事情:

for j=1:n
    Aj = something;
end

for jj=1:n
    do something with Ajj
end

【问题讨论】:

    标签: matlab


    【解决方案1】:

    如果我理解正确的话,听起来你必须进入第四维度:)

    %# pre-allocate
    A = zeros( <size of your cube>, n);
    
    %# generate cubes
    for j = 1:n
        A(:,:,:,j) = <your data cube>
    end
    
    %# use the data cubes
    for j = 1:n
        cube = A(:,:,:,j);
    end
    

    【讨论】:

      猜你喜欢
      • 2019-10-19
      • 2016-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-13
      • 1970-01-01
      相关资源
      最近更新 更多