Borrar filtros
Borrar filtros

How to split array which is discontinuous and plot them?

5 visualizaciones (últimos 30 días)
Josh Hwa
Josh Hwa el 26 de Abr. de 2019
Comentada: Josh Hwa el 26 de Abr. de 2019
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]

Respuestas (1)

KSSV
KSSV el 26 de Abr. de 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 comentario
Josh Hwa
Josh Hwa el 26 de Abr. de 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..

Iniciar sesión para comentar.

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by