How to assign character/string in the for loop

15 ビュー (過去 30 日間)
Turbulence Analysis
Turbulence Analysis 2022 年 2 月 12 日
編集済み: Stephen23 2022 年 2 月 12 日
Hi,
I am defining the character fname = '*A'
I need to use this chracter insdie the for loop as follows, fname(i)={load(flist(i).name)};
Basically, while exceuting, this needs to run as A(i)={load(flist(i).name)};
fname = '*A'
filename = strcat(fname_strt,'mean*');
flist=dir (filename);
for i=1:1
name{i}=flist(i).name;
fname(i)={load(flist(i).name)};
end
  2 件のコメント
Stephen23
Stephen23 2022 年 2 月 12 日
編集済み: Stephen23 2022 年 2 月 12 日
It is simpler to store the imported file-data in the same structure that DIR returns:
S = dir(..);
for k = 1:numel(S)
F = S(k).name;
S(k).data = load(F);
end
Note that you can easily get a cell array of the filenames without any loop:
C = {S.name};
Turbulence Analysis
Turbulence Analysis 2022 年 2 月 12 日
Thanks a lot.. stephen..
This is awesome...

サインインしてコメントする。

採用された回答

Catalytic
Catalytic 2022 年 2 月 12 日
name={flist.name};
n=numel(name);
S.(fname)=cell(n,1);
for i=1:1
S.(fname){i}=load(flist(i).name;
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by