check for a word
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I need to check if the current folder name contains words: YES or DYES.
such that:
if it contains YES:
a=1
if it contains DYES:
a=2
code I'm starting with:
Folder=pwd;
[PathStr,FolderName]=fileparts(Folder);
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 9 Nov. 2011
if strfind(FolderName, 'YES'); a = 1; end
if strfind(FolderName, 'DYES'); a = 2; end
What if the folder name contains both? Or neither? What if the folder name contains the word but in lower case?
4 Kommentare
Jan
am 9 Nov. 2011
Therefore Walter checks for YES at first and for DYES afterwards.
I assume he will apply a proper code formatting also in the near future.
Walter Roberson
am 9 Nov. 2011
I should, though, improve my code to:
if ~isempty(strfind(FolderName, 'YES')); a = 1; end
if ~isempty(strfind(FolderName, 'DYES')); a = 2; end
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Variables 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!