フィルターのクリア

Problem with identification of strings

1 回表示 (過去 30 日間)
ludvikjahn
ludvikjahn 2015 年 2 月 25 日
編集済み: Guillaume 2015 年 2 月 25 日
Good Mornig,
could you find a solution for this: if I input:
files = dir(fullfile(open_folder, '*140821*.txt'));
it finds a structure array, anyway, if I try with:
b=strcat('*','140821','*')
files = dir(fullfile(open_folder, 'b.txt'));
It doesn't find any.
I would like to name a 'b' and than find the related file in the directory but that doesn't seem the right way!!
Could you help me?

採用された回答

Guillaume
Guillaume 2015 年 2 月 25 日
編集済み: Guillaume 2015 年 2 月 25 日
files = dir(fullfile(open_folder, [b '.txt']));
or
files = dir(fullfile(open_folder, strcat(b, '.txt')));
or
files = dir(fullfile(open_folder, sprintf('%s.txt', b)));
The last one is my personal preference, and I would build b the same way:
b = sprintf('*%d*', 140821);
Note that in 'b.txt' the b is just the character 'b', there's no reason matlab would interpret it as the variable b.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by