Selecting values from an array when the array changes?
Ältere Kommentare anzeigen
I want to select pairs from an array, with the array changing size, there is no specification of the size that the array can be. The numbers in the array are not ordered.
For X = [ 1 2 3 4 5 6]
I would get LINK = [1 2] [2 3] [3 4] [4 5] [5 6]
For X = [1 2 3]
I would get LINK =[1 2] [2 3]
In my code LINK would be a temporary variable and would loop through each value it can be.
Thanks
Antworten (1)
Guillaume
am 30 Mär. 2016
How about:
link = [x(1:end-1); x(2:end)]'
and iterate over the rows. Or if you really want to have individual arrays in a cell array:
link = num2cell([x(1:end-1); x(2:end)]', 2)
Kategorien
Mehr zu Get Started with Phased Array System Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!