splitting matrix using while loop

I have matrix called x. when I run the MATLAB, x creates a random matrices. For example, if it creates the 1x650 matrix, i have to split this matrix _ by using while loop_ into 7 segments (Each segment will be of length 100, except for the last one which will be of length 50). I have to use while loop for my assignment. I just need the splitting part.

回答 (2 件)

James Tursa
James Tursa 2017 年 11 月 23 日

0 投票

Hint, if x is your data then x(1:100) will be the first part, x(101:200) will be the second part. Etc.
Walter Roberson
Walter Roberson 2017 年 11 月 23 日

0 投票

for K = 1 : 7
segment{K} = ....
end
  • For K = 1 you need to extract 1 to 100
  • for K = 2 you need to extract 101 to 200
  • for K = 3 you need to extract 201 to 300
So for K = N you need to extract the 100 items ending at N*100, with the exception of the very last iteration.

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2017 年 11 月 23 日

回答済み:

2017 年 11 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by