Creating an ascii map for each value of a table

2 views (last 30 days)
For every value of the excel table I have to create an ASCII map like the one in the picture in which every place (-9999) is replaced with that value.
For example, a map with 2.8 (row 439 of the excel table) in each cell of the ASCII file (at the place of every -9999), another with 4.8 (row 440 of the table) and so on for every subsequent cell of the excel file, an essential thing is that the ASCII file has to have the exact header of the picture, empty spaces included.
What could be the best approach? The logical point of view is simple but I'm encountering some issues.
1.png
  2 Comments
Guillaume
Guillaume on 19 Jul 2019
For every value of the excel table
What excel table?
an ASCII map like the one in the picture
What do you call an ASCII map?
For example, a map with 2.8
What is a map with 2.8?
(row 439 of the excel table)
Again, what table?
in each cell of the ASCII file
What is a cell of an ASCII file?
Elena Benedetta Masi
Elena Benedetta Masi on 19 Jul 2019
The excel table on the right of the ASCII file in the picture.
This ASCII file is readable from ARCMAP (GIS) as a map, the header gives spatial coordinates, cell size, what is the no-data value, ecc. In this case this is a map with cells of 1 unit of lenght (1 meter) in which we have no data in every cell, so every -9999 that you see is a cell of the ASCII map. If i'm considering a parameter like for example the hourly rainfall fallen in the area (2.8 mm for every cell of the area) a would have the same ASCII map but with 2.8 for every -9999 of the picture.

Sign in to comment.

Answers (1)

Vinai Datta Thatiparthi
Vinai Datta Thatiparthi on 5 Aug 2019
Hi Elena!
It’s unclear from the description of your question how you wish to map the values between the Excel document and the values in the .txt file. I’m assuming that you would like to improve the data importing part of your code. For reading the data from the excel document, use the readtable function, and for reading the data from the .txt file, you may use textscan, which can be useful to remove the header information while importing the data.
After you have the data in arrays in MATLAB, you can map the values simply using indexing. Consider using the function find to get the values of interest. This is a simple way to get your expected values.
Hope this helps!

Tags

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!