Change variable name on each iteration in for loop MATLAB
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have large array P which is changing size and values in each iteration. I need to be able to change the title of my output array to match the given iteration, i.e. for bin 1.4 I would like output to be p1.4 or p14.
Can anyone help?
for bin = 1:0.1:2;
rows = find(DAT(:,27) > bin);
p{bin} = DAT(rows,:);
end
0 comentarios
Respuesta aceptada
Shaun VanWeelden
el 14 de Mzo. de 2013
If you changed the name, you would be making a new variable every time and I am not sure it is even possible to do this like you say, instead, here are two solutions:
N = the number of large arrays you have
Make a N x 2 cell array, collectionArray, put the large array in collectionArray{i,1} and the name in collectionArray{i,2} that way the name is easy to retrieve with the information.
Or Make a collectionStruct, and have a field for each array (named p14, etc.) and have your array be the value in that field, so to retrieve the data, you could just say collectionStruct.p14
Hope it helps!
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements 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!