[英]Octave/GRASS GIS .mat import error: 'map_data' undefined
I have a Matlab script that calculates a certain terrain-parameter (describing the theoretical shelter from and exposure to wind) based on a digital terrain model. 我有一个Matlab脚本,可以根据数字地形模型计算特定的地形参数(描述理论上的避风和暴露于风中)。 The script works both in Matlab and Octave and yields a matrix.
该脚本可在Matlab和Octave中使用,并产生一个矩阵。 Now: I am trying to couple this with a GRASS GIS shell script.
现在:我正在尝试将其与GRASS GIS Shell脚本结合使用。 I can call the script from GRASS, but I have problems getting the output back into GRASS.
我可以从GRASS调用脚本,但是在将输出返回到GRASS时遇到问题。 One way is to use the .mat format.
一种方法是使用.mat格式。 The problem is, however: When I export the result of the calculation (with
save -mat4-binary result.mat ans
) and try to import the .mat file into GRASS, the error is: 但是问题是:当我导出计算结果(使用
save -mat4-binary result.mat ans
)并尝试将.mat文件导入GRASS时,错误是:
ERROR: No 'map_data' array found in [...file]
错误:在[...文件]中找不到'map_data'数组
Similarly, when I load the file in Octave and try to display it 同样,当我在Octave中加载文件并尝试显示它时
load result.mat
imagesc(map_data), axis equal, axis tight, colorbar
the error is 错误是
error: `map_data' undefined near line 19 column 9
错误:第19行第9列附近未定义“ map_data”
error: evaluating argument list element number 1错误:评估参数列表元素编号1
When I export from Matlab, it is the same problem. 当我从Matlab导出时,这是同样的问题。
Where is the bug? 错误在哪里?
Any help is greatly appreciated. 任何帮助是极大的赞赏。
The "bug" is, your mat-file does not contain any variable named "map_data", I would guess your variable in the mat-file is named "ans". “错误”是,您的mat文件不包含任何名为“ map_data”的变量,我想您在mat文件中的变量名为“ ans”。 I would use
res=load result.mat
, then you get a struct with everything which is in the mat file. 我将使用
res=load result.mat
,然后您将获得一个结构,其中包含res=load result.mat
文件中的所有内容。 If you type in res.
如果输入
res.
autocomplete should list all variables inside the struct (not sure about octave), alternatively use fieldnames(res)
to list all variable names. 自动完成功能应列出结构中的所有变量(不确定八度),或者使用
fieldnames(res)
列出所有变量名。
/Update: /更新:
I took a short look into the documentation of grass. 我看了一下草的文档。 It expects predefined variable names, all beginning with map_*.
它需要预定义的变量名,所有变量名都以map_ *开头。 Instead of
代替
save -mat4-binary result.mat ans
you should rename your variables to match the documentation and save them using 您应该重命名变量以匹配文档并使用
save -mat4-binary result.mat map_*
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.