Operands to the || and && operators must be convertible to logical scalar values.
Show older comments
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 Comments
Walter Roberson
on 13 Oct 2019
all_peak(:,2)<p1_peak(:,2)
what is the intended meaning of that when all_peak is 16 x 2 and p1_peak is 12 x 2 ? How do you want 16 items to be compared to 12 items?
arunnagiri murrugesan
on 13 Oct 2019
Walter Roberson
on 13 Oct 2019
Okay, so when you get to all_peak(13,2) then what should it be compared to in p1_peak ?
Answers (1)
Fabio Freschi
on 13 Oct 2019
0 votes
If you work with arrays, use the single & and not &&
2 Comments
arunnagiri murrugesan
on 13 Oct 2019
Fabio Freschi
on 13 Oct 2019
Edited: Fabio Freschi
on 13 Oct 2019
So you are comparing arrays of different dimensions. Look at Walter’s comment
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!