create a matrix that keeps only the sequential numbers
4 ビュー (過去 30 日間)
古いコメントを表示
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:
3 件のコメント
Akira Agata
2023 年 8 月 3 日
What happens if the 1st column consists of two sequential numbers, like: [1 2 3 4 7 8 9 10]' ?
採用された回答
Stephen23
2023 年 8 月 3 日
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!