Importing an ascii file in to matlab
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hey all,
I am trying to import a rather hefty asc file (12GB) into Matlab (R2012a). It was originally a tif file which I had in ArcGIS as a DEM. I am trying to import it into Matlab to work out the volume between the DEM and a olane I have created using cftool.
When I used M=dlmread(demtest) it comes up with 'Undefined variable "demtest" or function "demtest.asc".'
Does any body have any ideas? I'm pretty new to matlab so English is you please :D Thanks
2 Commenti
Geoff Hayes
il 23 Apr 2014
Hi Katie,
What is demtest defined to be? MATLAB is assuming that it is a local variable (I get the same "Undefined variable" error when I run the line M=dlmread(demtest)).
The function dlmread is expecting its input to be a string to the path and filename. Something like:
fileToRead = '/Users/geoff/Documents/demtest.asc';
Or whatever the full path (and name) is to the file you want to read. Just remember that the input must be a string.
Geoff
Risposte (4)
dpb
il 23 Apr 2014
M=dlmread(demtest) [yields] 'Undefined variable "demtest" or function "demtest.asc".'
Because dlmread is expecting a file name but you didn't enclose the argument in quotes so Matlab thinks demtest is a variable.
Use
M=dlmread('demtest.asc');
instead
0 Commenti
Katie
il 23 Apr 2014
1 Commento
Geoff Hayes
il 23 Apr 2014
Katie - is it necessary to use all of the data in your 12GB file or can you uses a subset of it instead? I'm not familiar with the arcgridread function but the online documentation says that its input is Arc ASCII Grid format so if you could make this data coarser (reduce the resolution?) you will have a smaller set of data to work with. (I don't know if that is possible though…)
Geoff
Kelly Kearney
il 23 Apr 2014
What are the dimensions of your grid? Your probably going to have to divide your grid into smaller blocks to do the calculations.
Most of the Mapping Toolbox functions, like arcgridread, don't play well with large files, since they're designed to read everything in all at once, which as you've discovered can easily exceed memory limits. But arc ascii files follow a simple format, so you should be able to read it in in pieces and perform your calculations without holding the whole file in memory.
0 Commenti
Vedere anche
Categorie
Scopri di più su Environment and Settings in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!