% Play with fprintf
% Minas Spetsakis, Oct. 2019

fprintf('pi is an integer!!!\n pi = %d\n',round(pi));
fprintf('pi is a real (float or double)!!!\n pi = %f\n',pi);
fprintf('pi in engineering notation!\n pi = %e\n',pi);
fprintf('pi with many digits\n pi = %12.9f\n',pi);
fprintf('pi with few digits\n pi = %4.2f    :',pi);
% 4.2 means four characters in total, two of which after the dot
fprintf('pi with many leading zeros: %010.2f\n',pi);
fprintf('pi with many leading blanks: %10.2f\n',pi);
fprintf('pi with many trailing blanks: %-10.2f<- see them?\n',pi);
% fprintf recycles the format string to print large vectors
fprintf('recycle %6.4f\n',rand(10,1));
% or
fprintf('two at a time %6.4f, %3.1f\n',rand(10,1));