Azzera filtri
Azzera filtri

How to split array which is discontinuous and plot them?

6 visualizzazioni (ultimi 30 giorni)
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]

Risposte (1)

KSSV
KSSV il 26 Apr 2019
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 Commento
Josh Hwa
Josh Hwa il 26 Apr 2019
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..

Accedi per commentare.

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by