image thumbnail
from Essential MATLAB by Brian Hahn
Companion software for Essential MATLAB for Scientists and Engineers

taxLogical.m
inc = [5000 10000 15000 30000 50000];                        
                                                                      
tax = 0.1 * inc .* (inc <= 10000);                                          
tax = tax + (inc > 10000 & inc <= 20000) ...                 
                    .* (0.2 * (inc-10000) + 1000);     
tax = tax + (inc > 20000) .* (0.5 * (inc-20000) + 3000);                    
                                                                      
disp( [inc' tax'] );

Contact us at files@mathworks.com