create a matrix that keeps only the sequential numbers
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi! I need to create a matrix that keeps only the sequential numbers in the first column (and keep the corresponding number in the second column) and delete everything else. Here is an example:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1449102/image.png)
3 Commenti
Akira Agata
il 3 Ago 2023
What happens if the 1st column consists of two sequential numbers, like: [1 2 3 4 7 8 9 10]' ?
Risposta accettata
Stephen23
il 3 Ago 2023
S = load('CountArray_A_zoom_select.mat');
A = S.CountArray_A_zoom_select
X = diff(A(:,1))==1;
Y = [X;0]|[0;X];
B = A(Y,:)
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!