how to write a function to return -1 if string is not found in matlab??

1 回表示 (過去 30 日間)
Mohammed
Mohammed 2016 年 9 月 5 日
コメント済み: Image Analyst 2016 年 9 月 6 日
I wrote a function that finds a 3 digit number of a filename? i need to write an if statement to return -1 if this part of the file cannot be extracted ? how do i do that?
Thanks :)
  2 件のコメント
the cyclist
the cyclist 2016 年 9 月 5 日
There are several possible ways to do this. Can you post your code, or at least the part of it that attempts the extraction?
Image Analyst
Image Analyst 2016 年 9 月 6 日
ANY 3 digit number whatsoever, or only a specific 3 digit number that you specify in the input argument list along with the filename?

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

採用された回答

the cyclist
the cyclist 2016 年 9 月 5 日
if isempty(w)
w = -1;
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by