Error Operands to the || and && operators must be convertible to logical scalar values.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Armindo
am 7 Feb. 2019
Bearbeitet: Armindo
am 7 Feb. 2019
Names = {'RHip','RKnee','RAnkle'};
Why doing this works ok
if~isempty( strfind(Names{1}, 'Hip') || strfind(Names{2}, 'Knee'))
if~isempty( strfind(Names{1}, 'Hip') || strfind(Names{3}, 'Knee'))
but doing this gives the error Operands to the || and && operators must be convertible to logical scalar values.
if~isempty( strfind(Names{3}, 'Hip') || strfind(Names{2}, 'Knee'))
Note in code was missing the ~isempty (i already added it). Nevertheless this dont change the outcome. The problem is that when the first operation give an [ ] the outcome is an error
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 7 Feb. 2019
strfind can return empty and you cannot use && or || with empty .
strfind finds all occurrences and returns their index . It is not intended to directly answer the question of whether to pattern occurs somewhere Yes or No. With new enough MATLAB use contains()
0 Kommentare
Weitere Antworten (1)
Armindo
am 7 Feb. 2019
1 Kommentar
KALYAN ACHARJYA
am 7 Feb. 2019
Bearbeitet: KALYAN ACHARJYA
am 7 Feb. 2019
Please read the explanation form @Walter sir
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!