I have a 201x551 matrix of height values, collected by LIDAR, showing a tidal estuary. The estuary runs diagonally across the figure (SW to NE), and I need to create a 2D representation of a cross section through the estuary (i.e. a transect from NW to SE). How can I create a vector which bes represents the values between (1,1) and (201,551).
Thanks for your help,
Max

 Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 26 Sep 2017
Modifié(e) : Andrei Bobrov le 26 Sep 2017
Let A - your array.
[m,n] = size(A);
if m > n, ii = sub2ind([m,n],1:m,ceil((1:m)*n/m));
elseif m < n, ii = sub2ind([m,n] ,ceil((1:n)*m/n),1:n);
else, ii = 1:m+1:m*n;
end
out = A(ii);

Plus de réponses (0)

Catégories

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by