How to make statements intersect
1 view (last 30 days)
How can I make if command's statements intersect and after that receive the result. For example the answer for this code is 'noyesno' ....but I want it to be no, cause not all the elements of a and b are equal.
a=[0 1 2]
b=[1 1 3]
More Answers (1)
Bhaskar R on 21 Jan 2020
Edited: Bhaskar R on 21 Jan 2020
n=3; % length of the your vector i guess
a=[0 1 2];
b=[1 1 3];
% depends on n value
is_intersect = sum(a(1:n)==b(1:n))==n;
% if a and b vectors are same length
is_intersect = sum(a==b)==length(a);
Hope i got you !!