在MATLAB中查找for循环中向量的均值

时间:2017-06-08 08:51:43

标签: matlab mean

如何在mean循环中获取向量的for。向量v取决于k

for k = 1:n
   filename = 'file.txt';
   ...
   v = ... %the vector
   result = mean(v, 3); %mean along the 3rd dimension.; didn't work.
end

1 个答案:

答案 0 :(得分:0)

result初始化为单元格数组并继续存储表示。以下应该有效:

result = cell(n,1);
for k = 1:n
   filename = 'file.txt';
   ...
   v = ... %the vector
   result{k} = mean(v, 3); %mean along the 3rd dimension.; didn't work.
end