3-D矩阵的几个.mat文件的平均值

发布于 2025-02-11 16:16:31 字数 232 浏览 1 评论 0原文

我有几个.mat文件,它们全部都在纬度x经度x值的3-D矩阵中(70 x 70 x 8760)。

看起来像这样: 2000.mat-> (72 x 70 x 8760), 2001.mat-> (72 x 70 x 8760),直到2020年,

我需要沿第三维的长期平均值 - 值。结果应再次为3次(72 x 70 x 8760)的.mat文件。第一和第二维度不会改变。

我是Matlab的新手。

I have several .mat files, which are all in a 3-D matrix of latitude x longitude x value (70 x 70 x 8760).

It looks like this:
year2000.mat --> (72 x 70 x 8760),
year2001.mat --> (72 x 70 x 8760),until year 2020

I need the long-term mean along the third dimensions-the value. The result should be again a .mat file with 3-Dimension (72 x 70 x 8760). The first and second dimensions don't change.

I am very new to Matlab.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天冷不及心凉 2025-02-18 16:16:31

您在加载文件方面做得很好,但是由于您知道所有文件都以年开始可以做:

fn = dir('year*.mat');

然后,您加载文件,但是如果我理解正确,您想指的是年份,而不是每个年份年。因此,

data = zeros(72,70,8760);
for n=1:numel(fn)
      single_year = load(fn(n).name);
      data = data + single_year.variable ; 
 end

如果每个垫子中的变量中的变量,变量真的是名称吗?我只是使用了您写的内容,但是如果加载一个文件,应该检查您得到的内容。

现在,AVG只是n的总和:

 data=data./numel(fn);

you did well in loading the files but since you know all the files start with year you can do:

fn = dir('year*.mat');

Then, you load the files, but if I understand you correctly you want to mean the years, not each year. so,

data = zeros(72,70,8760);
for n=1:numel(fn)
      single_year = load(fn(n).name);
      data = data + single_year.variable ; 
 end

is variable really the name if the variable in each mat file? I just used what you wrote, but you should check what you get if you load a single file.

now the avg is just the sum over the n:

 data=data./numel(fn);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文