Sorting a large 3 column data set

3 Ansichten (letzte 30 Tage)
Patrick O'Mahony
Patrick O'Mahony am 31 Mär. 2020
Beantwortet: David Hill am 31 Mär. 2020
I have a large 3 column matrix of xyz elevation data in 1 meter intervals. The data corresponds to a 100 meter by 100 meter grid, and lists the data row by row, meaning that the y term changes by 1 every 100 values. The data begins in the top right corner of the 'grid', as shown:
x y z
0 100 34
1 100 35
2 100 23
...
0 99 54
1 99 45
2 99 37
...
etc.
My problem is that the x and y values start at arbitrarily assigned values, like 499983.5, which make the data hard to work with. How can I make a new matrix with the x and y redefined from 1 to 100? This still needs to account for the fact the dataset starts in the top right corner.

Akzeptierte Antwort

David Hill
David Hill am 31 Mär. 2020
If I understand you correctly, can you not just subtract off a constant from both x and y coordinates to reset them to where you want them?
M(:,1)=M(:,1)-min(M(:,1))+1;
M(:,2)=M(:,2)-min(M(:,2))+1;

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by