How to split array which is discontinuous and plot them?

10 ビュー (過去 30 日間)
Josh Hwa
Josh Hwa 2019 年 4 月 26 日
コメント済み: Josh Hwa 2019 年 4 月 26 日
I have a se of array like 'a' and I would like to split them into
[1 2 3 4 5 6 7 8 9]
[17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42]
[50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73]
[79 80 81 82 83 84 85 86 87 88]
Then, it can be plot by using plot(x(a),y(a),'-')
I have go through the split array question but it cant work on these kind of array.
Can someone guide me on this? Will be much appreciate.
a=[1 2 3 4 5 6 7 8 9 17 18 19 20 21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40 41 42 50 51 52 53 54 55 56 57 58 59 60
61 62 63 64 65 66 67 68 69 70 71 72 73 79 80 81 82 83 84 85 86 87 88]

回答 (1 件)

KSSV
KSSV 2019 年 4 月 26 日
a=[1 2 3 4 5 6 7 8 9 17 18 19 20 21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40 41 42 50 51 52 53 54 55 56 57 58 59 60
61 62 63 64 65 66 67 68 69 70 71 72 73 79 80 81 82 83 84 85 86 87 88] ;
a = a' ; a = a(:)' ;
L = [9 26 24 10] ; % required lengths
C = mat2cell(a,1,L);
  1 件のコメント
Josh Hwa
Josh Hwa 2019 年 4 月 26 日
Hi, your code works so fine but the length might be unknown as im using ginput. the 'a' array is just an example. Can it be done without knowing the length? Appreciate..

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

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by