Passing variable to array name

조회 수: 5 (최근 30일)
Carl
Carl 2013년 12월 18일
댓글: Carl 2013년 12월 19일
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
per isakson
per isakson 2013년 12월 18일
Carl
Carl 2013년 12월 19일
Thanks for that link! I had not seen that, and I've solved the problem now.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by