MATLAB Answers

How to make NxN matrix from excel dataset

2 views (last 30 days)
Hi there,
I got excel dataset which has longitude(1xn)), latitude(1xn) and elevation(1xn) as described in the attached file.
How can I convert elevation dataset into NxN matrix?
Note: Data points are randomly distributed. not in exact order as described in the example.


Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 8 Nov 2018


Show 1 older comment
Walter Roberson
Walter Roberson on 8 Nov 2018
data = xlsread('matlab_example.xslx');
N = size(data, 1);
Long = data(:, 1);
Lat = data(:,2);
Minlong = min(Long) ;
Maxlong = max(Long) ;
Longvec = linspace(Minlong, Maxlong, N) ;
Minlat = min(Lat) ;
Maxlat = max(Lat) ;
Latvec = linspace(Minlat, Maxlat, N) ;
Elev = data(:, 3);
Out = griddata(Long, Lat, Elev, Longvec(:), Latvec(:).');
Ravindu Lokuliyana
Ravindu Lokuliyana on 8 Nov 2018
Thank you very much. It works well for me.
But I got large excel data values (more than 300,000) in my file. In that case it's somewhat hard to execute.
If you have further suggestions, I would greatly appreciate.
Walter Roberson
Walter Roberson on 8 Nov 2018
Set N to a smaller value, probably not more than about 1500 or so.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by