I am trying to display a matrix that with numbers all rounded off to 1 decimal point. Currently when I round, there is a 0 that remains in the hundreths place of each number. I'd like to remove this last zero so that all my numbers only display out to the tenths place.
I have tried using the fprintf function as well as the sprintf function but I always lose the rows/column format of my matrix. Is there a way to round and then shorten an entire matrix of numbers so that there aren't any trailing zeros?
matrix = [1.34, 3.45, 2.34; 0.54, 21.34, 0.34; 11.81, 9.94, 10.02]; %3x3 matrix of data
round_matrix = round(matrix, 1); %3x3 matrix of data rounded to 1 decimal place
%My attempts thus far at removing the trailing zeros
disp_matrix = sprintf('%.1f', rounded_matrix); %This resulted in a string of all of my numbers mashed together
disp_matrix = fprintf('%.1f\n',round(Table_outnumeric)); %This resulted in all of my numbers being converted into a single column
Best Answer