E
E
Eugene2020-01-07 23:13:49
block diagram
Eugene, 2020-01-07 23:13:49

Optimizing Scilab Code and Building a Flowchart?

Made an algorithm for determining the number of elements belonging to the set A \ B (difference AB) and more than the set value.
For example:
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.

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);

I know there is a function
setdiff
Made a code to build a flowchart and an alternative to this function.
Now I need help with code optimization and flowchart construction. I will be grateful for any help.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question