How to convert matrix data from nc file to vector lon lat?
2 views (last 30 days)
Show older comments
does anyone can help me, i have data in ncfile, and successfully read using matlab with ncread and ncdisp function, then my data format was like this:
Variables:
time
Size: 1x1
Dimensions: time
Datatype: double
Attributes:
units = 'minutes since 0001-01-01 00:01:00.0'
calendar = 'gregorian'
latitude
Size: 801x1
Dimensions: latitude
Datatype: single
Attributes:
units = 'degrees_north'
longitude
Size: 1801x1
Dimensions: longitude
Datatype: single
Attributes:
units = 'degrees_east'
DEN
Size: 1801x801x1
Dimensions: longitude,latitude,time
Datatype: single
Attributes:
least_significant_digit = 4
how i can can convert it become vector with this format: latitude,longitude,DEN ?
example:
lat\lon 101 102 103 .......
15 1 2 3
16 4 5 6
17 7 8 9 ......
....
become:
15, 101 = 1
15, 102 = 2
15, 103 = 3
16, 101 = 4
16, 102 = 5
16, 103 = 6
.....etc
thanks in advance...
0 Comments
Accepted Answer
Andrei Bobrov
on 29 Sep 2014
Edited: Andrei Bobrov
on 29 Sep 2014
la0=ncread('yourncfile','latitude');
lo0=ncread('yourncfile','longitude');
d = ncread('yourncfile','DEN');
[la,lo]=ndgrid(la0,lo0);
out = [la(:),lo(:),d(:)];
sprintf('%f, %f = %f\n', out')
More Answers (1)
Md. Sazzad
on 13 Nov 2014
I am using the same command but getting the following error
Error using horzcat Dimensions of matrices being concatenated are not consistent.
Error in testnc (line 7) out = [la(:),lo(:),t(:)];
0 Comments
See Also
Categories
Find more on NetCDF in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!