Calculations on every 2nd row in a matrix in sets of 2 rows
Show older comments
I have a matrix of x and y points with 2 columns and n number of rows.
The first column is the x data (distance) and the 2nd coloumn is the y data (height (or depth in this case as they are underwater)). Each row represents a specific point on a topographic profile relating to either the top or bottom of a scarp so every two rows define the top and bottom of a specific scarp i.e., row 1 represents the top of a scarp and row 2 represents the bottom. Row 3 represents the top of a another scarp and row 4 represents the bottom of this other scarp, and so on. I want to calcualte the slope and height for each scarp. Therefore, I need to calculate the change in x and the change in y for each set of 2 rows representing the top and bottom of each scarp. I can't figure out how. Perhaps I need a loop?
An example of the data is as follows:
x (distance) y (Depth)
3704.43613041155 -1705.01061571125
3839.12346338856 -1751.88959660297
3973.81079636558 -1748.49256900212
4063.60235168359 -1762.76008492569
4211.11704970604 -1738.98089171975
4390.70016034206 -1787.89808917197
4814.00320684126 -1749.17197452229
4852.48530197755 -1766.15711252654
5570.81774452165 -1684.62845010616
5788.88295029396 -1742.37791932059
6526.45644040620 -1662.88747346072
6558.52485301978 -1683.26963906582
Many thanks in advance
Accepted Answer
More Answers (1)
madhan ravi
on 16 Sep 2020
matrix(1 : 2 : end, :) - matrix(2 : 2 : end, :) % ?
1 Comment
Alex Hughes
on 16 Sep 2020
Categories
Find more on Logical 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!