Passing variable to array name

5 visualizzazioni (ultimi 30 giorni)
Carl
Carl il 18 Dic 2013
Commentato: Carl il 19 Dic 2013
Hi,
I'm currently trying to pass variable N in to the name of an array. The process I'm coding is given below:
for N = 1:totalblocks
Output_{N} = ones(ttotal,cells);
if cells*N < ntotal
cells = cells;
Output_{N} = ones(ttotal,cells);
for j=1:ttotal
path = char(files(j).name);
fprintf('Merging %d of %d, from block %d\n',j-1,ttotal,N);
Output_{N}(j,:) = extractOMF_v1(nx,ny,nz,path,ntotal,N,cells);
end
else
cells = ntotal;
Output_{N} = ones(ttotal,cells);
for j=1:ttotal
path = char(files(j).name);
fprintf('Merging %d of %d, from block %d\n',j-1,ttotal,N);
Output_{N}(j,:) = extractOMF_v1(nx,ny,nz,path,ntotal,N,cells);
end
end
save(strcat('spatially_resolved_',num2str(N),'.txt'),strcat('Output_',num2str(N)),'-ascii')
end
So, let us just consider totalblocks = 1. Then I would like the array 'Output_N' to be named 'Output_1'. This will let me save multiple 'Output' arrays.
When I run this however, the array is simply named 'Output_N'. Does anyone know how I can get 'Output_1' as an output? I get the feeling I'm missing something very obvious!
Many thanks,
Carl
  2 Commenti
Carl
Carl il 19 Dic 2013
Thanks for that link! I had not seen that, and I've solved the problem now.

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by