So I am trying to round my number my current output is giving me 4 decimal places after the period 127.1234 im trying to make look like this 127.12. i have tried all formats of rounding and have multiple by 100 and divide by 100 nothing really seems to work.
oad a02_data.matsub_tot = sum(purchases(:,1));sub_tot_0 = 0;sub_tot_1 = 0;sub_tot_2 = 0;tax_tot_0 = 0;tax_tot_1 = 0;tax_tot_2 = 0;L = length(purchases(:,1));for ind = 1:L if purchases(ind,2) == 0 sub_tot_0 = sub_tot_0 + purchases(ind,1); tax_tot_0 = tax_tot_0 + tax_rates(1)*purchases(ind,1); elseif purchases(ind,2) == 1 sub_tot_1 = sub_tot_1 + purchases(ind,1); tax_tot_1 = tax_tot_1 + tax_rates(2)*purchases(ind,1); elseif purchases(ind,2) == 2 sub_tot_2 = sub_tot_2 + purchases(ind,1); tax_tot_2 = tax_tot_2 + tax_rates(3)*purchases(ind,1); endendtot = sum([tax_tot_0,tax_tot_1,tax_tot_2,sub_tot_0,sub_tot_1,sub_tot_2]);format shortdisp('subtotal for purchases in tax rate 0')disp(round(sub_tot_0*100)/100)disp('Total taxes in category 0')disp(round(tax_tot_0*100)/100)disp('subtotal for purchases in tax rate 1')disp(round(sub_tot_1*100)/100)disp('Total taxes in category 1')disp(round(tax_tot_1*100)/100)disp('subtotal for purchases in tax rate 2')disp(round(sub_tot_2*100)/100)disp('Total taxes in category 2')disp(round(tax_tot_2*100)/100)disp('Subtotal is')disp(round(sub_tot*100)/100)disp('Total is')disp(round(tot*100)/100);
Best Answer