How to read matrix but skip rows

67 ビュー (過去 30 日間)
Kevin
Kevin 2022 年 9 月 30 日
コメント済み: Image Analyst 2022 年 9 月 30 日
I am tring to use the read matrix and split the data into 4 different values, I want the variables to be, for example, [row 1, row 5, row 9, row 13, row 17, etc...]. I would like it to skip 4 rows in between each value taken if that is possible.

回答 (1 件)

Image Analyst
Image Analyst 2022 年 9 月 30 日
Try this:
m = readmatrix(filename);
[rows, columns] = size(m)
% Split into 4 matrices
m1 = m(1 : 4 : rows, :);
m2 = m(2 : 4 : rows, :);
m3 = m(3 : 4 : rows, :);
m4 = m(4 : 4 : rows, :);
You can learn other basic things like indexing here:
  2 件のコメント
Kevin
Kevin 2022 年 9 月 30 日
Thank you, that worked
Image Analyst
Image Analyst 2022 年 9 月 30 日
Can you then please click the "Accept this answer" link? Thanks in advance! 🙂

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by