필터 지우기
필터 지우기

How to put the numbers of cell array in a new cell array

조회 수: 1 (최근 30일)
Farshid Daryabor
Farshid Daryabor 2016년 11월 7일
댓글: Farshid Daryabor 2016년 11월 9일
Hi,
Actually I have defined a cell "B" (1*3 cell). As the each cell array of "B" is defined for the numbers of the cast number (i.e., B{1,1} is 1043x1 cell, B{1,2} is 18x1 cell, B{1,3} is 397x1 cell). The following code (for i=1:length(B)), read and write certain the "nc" files from the home directory based on the cast number defined in "B".
for j = 1 : length(B{i}(:))
data{j}=sprintf('%s%s_0%sO.nc', directory,'obs',B{i}{j});
end
I tried to put the above code in the other loop. It should to read the separate path and file name from the each cell defined based on the numbers of the cast in "B", and write in a new cell in the same cell size of "B".
I tried for the different loops, unfortunately doesn't work.
e.g.,
C2=1;
for i = 1 : length(B)
for j = 1 : length(B{i}(:))
Data1{C2}=sprintf('%s%s_0%sO.nc', directory,'obs',B{i}{j});
C2=C2+1;
end
Data2{i}=Data1;
end
Or
count=0;
for i = 1 : length(B)
count=count+1;
for j = 1 : length(b{i}(:))
data{j}=sprintf('%s%s_0%sO.nc', directory,'obs',B{i}{j});
end
Data{count}=data;
end
Thanks, if anybody can help me. Cheers,
  댓글 수: 1
Farshid Daryabor
Farshid Daryabor 2016년 11월 9일
Thanks users, I was able to fix my problem. Sincerely yours

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by