How can I cut or split the data fast?

3 visualizaciones (últimos 30 días)
pty0220
pty0220 el 8 de Ag. de 2017
Editada: the cyclist el 8 de Ag. de 2017
I have some data like
A =
2 3 4
2 3 4
2 3 4
5 3 2
5 3 2
5 3 2
9 4 2
9 4 2
9 4 2
or
B=
3 5 6
7 8 1
4 9 0
3 5 6
7 8 1
4 9 0
and I want to split this data like this
a1 = a2 = a3 =
2 3 4 5 3 2 9 4 2
2 3 4 5 3 2 9 4 2
2 3 4 5 3 2 9 4 2
or
b1= b2=
3 5 6 3 5 6
7 8 1 7 8 1
4 9 0 4 9 0
This is easy question if i use 'for loop' but, I will work with large data so speed is very important for me
is there any way to solve this issue without 'for loop'??

Respuestas (1)

the cyclist
the cyclist el 8 de Ag. de 2017
Editada: the cyclist el 8 de Ag. de 2017
It is a very bad idea to name variables like this. You can find scores of posts here about that.
What is your underlying purpose for this? What is your next step? An alternative would be to simply reshape your array:
A_r = reshape(A,3,3,[]);
and then access, for example,
A_r(:,:,1)
in the same way you would have used a1.

Categorías

Más información sobre 루프와 조건문 en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!