Operands to the || and && operators must be convertible to logical scalar values.

2 Ansichten (letzte 30 Tage)
cl=input('Enter class ( up-1 or down-2 or blink-3): ');
if cl==1
[k,~]=find((all_peak(:,2)>0)&&((all_peak(:,2)<p1_peak(:,2))))
% % [k,~]=find(all_peak(:,2)<0);
ch_n='up';
elseif cl==2
[k,~]=find(all_peak(:,2)<0);
% % [k,~]=find((all_peak(:,2)>0)&&((all_peak(:,2)<allnew_peak(;,2)));
ch_n='down';
else
[k,~]=find(all_peak(:,2)>0);
ch_n='blink';
end
where all_peak =[16,2] matrix , p1_peak =[12,2 ] matrix , allnew_peak=[12,2] matrix. i am getting error. Operands to the || and && operators must be convertible to logical scalar values. how to solve it ?
  3 Kommentare
arunnagiri murrugesan
arunnagiri murrugesan am 13 Okt. 2019
lets take all_peak [16,2] = 1542 15.56 p1_peak[12,2] = 1243 13.06
1342 -21.43 1453 24.54
i want to compare 15.56 with 13.06 , -21.43 with 24.54
Walter Roberson
Walter Roberson am 13 Okt. 2019
Okay, so when you get to all_peak(13,2) then what should it be compared to in p1_peak ?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Fabio Freschi
Fabio Freschi am 13 Okt. 2019
If you work with arrays, use the single & and not &&
  2 Kommentare
arunnagiri murrugesan
arunnagiri murrugesan am 13 Okt. 2019
Matrix dimensions must agree. i am getting popped with this error when i use single &
Fabio Freschi
Fabio Freschi am 13 Okt. 2019
Bearbeitet: Fabio Freschi am 13 Okt. 2019
So you are comparing arrays of different dimensions. Look at Walter’s comment

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by