cell array in a cell array inexing

1 visualización (últimos 30 días)
HYZ
HYZ el 23 de Mayo de 2020
Comentada: Federico Zappaterra el 25 de Mayo de 2020
Hi,
a = { [1:30] }. A {1} = { [1 2 3] [11 12 13] [21 22 23] }. A is resulted from a by extracting values from a.
b = { [41:70] }. I would like to get B = { [4142 43] [51 52 53] [61 62 63] } based on indexing from a and A.
I am confused from double indexing for cell array. I tried like B {1} = { b{1} (B {1})} and got error.
Could anyone help please ? thank you.

Respuesta aceptada

Federico Zappaterra
Federico Zappaterra el 23 de Mayo de 2020
I'm not sure about what are you looking for. However, I would do the following:
k1 = 1:3;
k2 = 6:9;
k3 = 11:13;
a{1} = [1:20];
A{1} = {a{1}k1 a{1}k2 a{1}k3};
b{1} = [31:50];
B{1} = {b{1}k1 b{1}k2 b{1}k3};
  2 comentarios
Federico Zappaterra
Federico Zappaterra el 25 de Mayo de 2020
Cool, I really didn't know about that! Thank you Stephen!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing 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