In stead of using multiple if-else or switch-case, is there a way of switching functions smartly?
Take if as an example:
for i = 1 : n if a out(i) = function1(p1,p2,p3); else if b out(i) = function2(p1,p2,p3); else if c out(i) = function3(p1,p2,p3); else out(i) = function4(p1,p2,p3); end end endend
Maybe something like funMap = containers.map(key,{function1,…function4}??? So the code will look like:
for i = 1:n key = ...; out(i) = funMap(key); end
Any thoughts? Thanks in advance!
Best Answer