Creating a matrix from spaced out lines of another matrix
Show older comments
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.
I would like to write a function that creates a smaller matrix corresponding to a 3 meter by 3 meter portion of the grid, but because of the large matrix's construction, the nine lines of data are grouped in three sets of three, each spaced around 100 lines from the next. Any advice and assistance would be appreciated.
2 Comments
the cyclist
on 31 Mar 2020
Is your matrix stored in a numeric data type (such as a double), or in a cell array, table, or other data type?
So, you want to enter the center coordinates (x,y) -- suppose they are 43, 52 -- and then get output
42 51 72
43 51 77
44 51 68
42 52 72
43 52 71
44 52 62
42 53 72
43 53 77
44 53 63
?
Patrick O'Mahony
on 31 Mar 2020
Accepted Answer
More Answers (1)
darova
on 1 Apr 2020
Try this
dx = max(x)-min(x);
ix = round((x-min(x))/max(x)*2) + 1; % result 1 2 3
ind = cell(3,1);
for i = 1:length(ind)
ind{i} = x(ix==i); % write data
end
Categories
Find more on Time Series Events in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!