Filter löschen
Filter löschen

Problem with identification of strings

1 Ansicht (letzte 30 Tage)
ludvikjahn
ludvikjahn am 25 Feb. 2015
Bearbeitet: Guillaume am 25 Feb. 2015
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?

Akzeptierte Antwort

Guillaume
Guillaume am 25 Feb. 2015
Bearbeitet: Guillaume am 25 Feb. 2015
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.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by