Incremental indexing to create an array

6 views (last 30 days)
I have a 1097x1097 array (called list_of_distances) and would like to index into that array repeatedly; I only need certain values from the array. By doing this repeated indexing, I'd like to create new array that is 1x1097 of values. I included a screen shot of the values I'm looking to get into a new array.
Any help would be appreciated
R = 2
S = 1
for i = length(list_of_distances)
final_list(i) = list_of_distances(R,S)
R = R+1
S = S+1

Accepted Answer

Peng Li
Peng Li on 15 Apr 2020
using diag(list_of_distances, -1) to get the diagonal you want.
Michael King
Michael King on 15 Apr 2020
thanks, I've learned a lot here! much appreciated

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