How to split array which is discontinuous and plot them?
조회 수: 2 (최근 30일)
이전 댓글 표시
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]
댓글 수: 0
답변 (1개)
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);
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!