[英]Matlab/Octave: How to resize a .mat file? Reduce resolution of data for smaller file/data set size
I have a Matlab data set file which contains data for a grid [X , Y]
.我有一个 Matlab 数据集文件,其中包含网格[X , Y]
。 I would like to reduce the resolution of the data set file to [P , Q]
, where P = X / scale
and Q = Y / scale
.我想将数据集文件的分辨率降低到[P , Q]
,其中P = X / scale
和Q = Y / scale
。 So for example if the data set is originally 1400 x 800
and I want to scale it down by a factor of 10
I will get a new data set file with resolution 140 x 80
.因此,例如,如果数据集最初是1400 x 800
并且我想将其缩小10
倍,我将获得一个分辨率为140 x 80
的新数据集文件。 How would this be done in Matlab and/or Octave?这将如何在 Matlab 和/或 Octave 中完成?
If instead there is an easy way to convert Matlab (*.mat) files into NetCDF
then I can easily take it from there, please reference if so (I haven't found anything using basic Google search).相反,如果有一种简单的方法可以将 Matlab (*.mat) 文件转换为NetCDF
那么我可以轻松地从那里获取它,如果是这样,请参考(我没有使用基本的 Google 搜索找到任何内容)。 I'm aware of ncwrite
but there's a catch-22 of sorts with that because I can't read the data in the first place because the .mat file is too large for my environment (I'm trying to avoid building Octave for 64-bit address space, and instead use a smaller data set while doing development).我知道ncwrite
但有一个 catch-22,因为我首先无法读取数据,因为 .mat 文件对于我的环境来说太大了(我试图避免为 64 构建 Octave -bit 地址空间,而在进行开发时使用较小的数据集)。
I'm using Octave on Windows now, so I'd prefer to pull this off with Octave or another non-Matlab tool, but I may have access to a proper Matlab version soon.我现在在 Windows 上使用 Octave,所以我更喜欢用 Octave 或其他非 Matlab 工具来实现这一点,但我可能很快就会获得合适的 Matlab 版本。
Any suggestions are very appreciated, thanks for your help.任何建议都非常感谢,感谢您的帮助。
Easiest way I can think of is by dividing the original vectors/matrices from the .math file by the scale you want, apply a rounding function and, finally, the unique() function.我能想到的最简单的方法是将 .math 文件中的原始向量/矩阵除以您想要的比例,应用舍入函数,最后应用 unique() 函数。
For example:例如:
octave:1> x=1:20
x =
Columns 1 through 16:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Columns 17 through 20:
17 18 19 20
octave:2> y = round(x/4)
y =
0 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5
octave:3> unique(y)
ans =
0 1 2 3 4 5
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.