How can i remove this logical operator error?

3 ビュー (過去 30 日間)
Febin Benjamin
Febin Benjamin 2014 年 6 月 30 日
コメント済み: Febin Benjamin 2014 年 6 月 30 日
Operands to the || and && operators must be convertible to logical scalar values.
Error in parentProgram (line 2)
if((positive_sum<datestr('0,30','HH,MM')) && (negative_sum<datestr('1,00','HH,MM')))
Where am i going wrong?

採用された回答

Jos (10584)
Jos (10584) 2014 年 6 月 30 日
One of the terms is not convertible to a logical scalar. Most likely, one or both of these terms are arrays. What does
size(positive_sum<datestr('0,30','HH,MM')
give you? It should be 1x1 to be used in conjunction with &&.
May be the functions ALL or ANY can help you out:
if all((positive_sum<datestr('0,30','HH,MM')) && all (negative_sum<datestr('1,00','HH,MM')))
  1 件のコメント
Febin Benjamin
Febin Benjamin 2014 年 6 月 30 日
Thanks. Fixed :-)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by