フィルターのクリア

How can i take an error without using try catch ?

2 ビュー (過去 30 日間)
ahmet ozdemir
ahmet ozdemir 2016 年 5 月 3 日
編集済み: Jan 2016 年 5 月 3 日
Hi, My condition is something like this (()) +4 If parenthese is empty, code should give an error not only four parenthesis but also infinitive parenthesis String can use for determining error. Also parenthesis take an input with numbers.
  3 件のコメント
ahmet ozdemir
ahmet ozdemir 2016 年 5 月 3 日
編集済み: ahmet ozdemir 2016 年 5 月 3 日
My program evaluate number like 3+4 =7 but if i give like ((()))+3+4 it should give an error since parenthesis is empty. Only empty parenthesis conditon should be thought. I hold on other type of thing like open parenthesis. It should be for empty parenthesis
Adam
Adam 2016 年 5 月 3 日
If you are asking what your question title says then:
error( ... )
throws an error and
assert( condition, ... )
asserts that a condition is true and throws an error if it isn't. The body of your question seems to concern other matters that are potentially vastly more complicated though and seem to be effectively trying to write your own parser.

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

回答 (1 件)

Jan
Jan 2016 年 5 月 3 日
編集済み: Jan 2016 年 5 月 3 日
Str = '((( ))) + 3 + 4';
Str = Str(~isspace(Str)); % remove spaces
if any(strfind(Str, '()'))
disp('Empty parenthesis found!');
end

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by