Azzera filtri
Azzera filtri

How can i remove this logical operator error?

1 visualizzazione (ultimi 30 giorni)
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?

Risposta accettata

Jos (10584)
Jos (10584) il 30 Giu 2014
One of the terms is not convertible to a logical scalar. Most likely, one or both of these terms are arrays. What does
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')))

Più risposte (0)


Scopri di più su Data Type Conversion in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by