I found my code spent a lot of cpu time on the following functions:
- intersect, took 20.11 seconds, called 232074 times in my code.
C = intersect(A,B); where A and B are two column arrays.
2. unique, took 8.845 seconds, called 251736 times in my code.
BadMeas = unique([A; red2(B)']); where A and B are two column arrays, red2 is another row array.
3. ismember, took 7.117 seconds, called 269278 times in my code.
if ismember(selectedBus, InjBus_moreZeroLines)
4. setdiff, called 13103 times in my code.
red = setdiff([1:length(A)],B);
A is an array and B is an array formed by integers.
I am wondering if there are faster functions to replace the above ones. Thanks.