Matrix indexing - Picking columns
3 ビュー (過去 30 日間)
古いコメントを表示
So I trying to give an output a matrix which contains every fifth column of input (A). Below is what my current script look like.
function B = Script30( A )
B = A(:,1:5:end);
end
5 件のコメント
採用された回答
David Fletcher
2018 年 4 月 15 日
Do you mean this instead of your 1:5:end?
5:5:end
If you explicitly also want column 1 the you could use [1 5:5:end]
12 件のコメント
David Fletcher
2018 年 4 月 15 日
What the first colon? It means all rows and columns 5,10,15...etc. If you don't have the first colon - as you have found - it will compact all selected columns into one row. Well that was a bit harder than it should have been, I think I need a lie down.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!