フィルターのクリア

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 Center および File ExchangeC Shared Library Integration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by