0
How else can I optimization this code?

I am builded an algorithm for determining the number of elements belonging to the set A \ B (difference A-B) and more than the set value.

For instance: A = {1,2,3,5,8}, B = {0,1,3,4,8,9,10} and the set value is 3. A \ B = {2,5}, but there is one element greater than 3. This value is 5.

I need help with code optimization and creating a flowchart.

Scilab 6.0.2

A = [-1,0,1,2,3,5,6,8,10,13,19,23,45];
B = [0,1,3,6,7,8,9,12,45];
N1 = length(A);
N2 = length(B);
t = 1;
m = 10;
C = [];
for i=1:N1
    for j=1:N2 
        if A(i)==B(j)
            break
        else
            if j==N2
               C(t)=A(i);
               t=t+1;
           end
       end
   end
end
disp(C);
N3=length(C);
R = [];
y = 1;
for l=1:N3
    if C(l)>m
       R(y)=C(l);
       y=y+1;
   end 
end
disp(R);


Scilab 08-01-20, 3:05 a.m. SwissMan
0

You may want to take a look at the function intersect.

08-01-20, 9 a.m. rupakrokade


Log-in to answer to this question.