Question about searching a number in file suffix
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ivan Mich
am 5 Dez. 2022
Beantwortet: Dyuman Joshi
am 5 Dez. 2022
I have a question about a command I would like to use. I have several files with multiple suffixes, for example file_1.txt, file_2.txt, file_3.txt etc.
I would like to read a specific file depending on a value of a variable. For example if my value is equal to 4 I would like to read file file_4.txt. if my value is equal to 5 I would like to read file file_5.txt.
Which command should I use in order to make it?
Coule you please help me?
0 Kommentare
Akzeptierte Antwort
Dyuman Joshi
am 5 Dez. 2022
d=5;
s=sprintf('file_%d.txt',d)
%command for reading the file
fileread(s)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Search Path finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!