简体   繁体   中英

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. The script works both in Matlab and Octave and yields a matrix. Now: I am trying to couple this with a GRASS GIS shell script. I can call the script from GRASS, but I have problems getting the output back into GRASS. One way is to use the .mat format. 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:

ERROR: No 'map_data' array found in [...file]

Similarly, when I load the file in Octave and try to display it

load result.mat 
imagesc(map_data), axis equal, axis tight, colorbar

the error is

error: `map_data' undefined near line 19 column 9
error: evaluating argument list element number 1

When I export from Matlab, it is the same problem.

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". I would use res=load result.mat , then you get a struct with everything which is in the mat file. If you type in res. autocomplete should list all variables inside the struct (not sure about octave), alternatively use fieldnames(res) to list all variable names.

/Update:

I took a short look into the documentation of grass. It expects predefined variable names, all beginning with 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_*

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM