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);

 採用された回答

Walter Roberson
Walter Roberson 2011 年 11 月 9 日

0 投票

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 件のコメント

Baba
Baba 2011 年 11 月 9 日
in this case it's not possible for the other sittuations to occur
Baba
Baba 2011 年 11 月 9 日
please diregard my last comment
i'm getting an error:
Illegal use of reserved keyword "if".
for the end if line
Jan
Jan 2011 年 11 月 9 日
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
Walter Roberson 2011 年 11 月 9 日
I should, though, improve my code to:
if ~isempty(strfind(FolderName, 'YES')); a = 1; end
if ~isempty(strfind(FolderName, 'DYES')); a = 2; end

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Simulink Check についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by