Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
cells related
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
KSSV
el 12 de Abr. de 2012
Cerrada: MATLAB Answer Bot
el 20 de Ag. de 2021
Hi all
I have 450 matrices of order 4X2. I am saving them in a cell on the name, say Vn. So size of Vn is 450X1. And size of each cell is 4X2. Now I want to run a loop and pick the elements randomly from Vn. For example I want to pick 1, 2, 3, 4 rows from the cells 1, 2, 31 , 32. I can access these elements in the way:
Vn{1}(1,:), Vn{2}(2,:), Vn{31}(3,:) etc. As I am running a loop and picking the values randomly, this kind of calling the rows may take long time for the code to run task. Is there any fast / best way to do this?
Thanks in advance Sreenu
0 comentarios
Respuesta aceptada
Andrei Bobrov
el 12 de Abr. de 2012
variant
numcell = randperm(numel(Vn),4);
rows1 = 1:4;
datarnd = arrayfun(@(x,y)Vn{x}(y,:),numcell,rows1,'un',0);
out = cat(1,datarnd{:});
0 comentarios
Más respuestas (1)
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!