%% Save and Restore Display Settings
% This example shows how to use format to save the current display settings and restore them at a later time.
% Set the numeric display format to short, scientific format.

format shortE

%
% Create and display a 2-by-2 matrix of numeric values.

m = [9638573934 37467; 236 574638295]

%
% Use format with both input and output arguments to save the current settings and then change them. The function returns oldSettings, which contains the current format settings: short, scientific format with loose line spacing. Use the input argument "longE" to change the numeric format to long, scientific format.

oldSettings = format("longE")

%
% Confirm that the numeric format is now long, scientific notation and redisplay matrix m.

newSettings = format
m

%
% Call format with oldSettings as an input to restore the settings to their previous values. Redisplay m to confirm that the numeric format is now short, scientific format.

format(oldSettings)
m

%
%
% Copyright 2020 The MathWorks, Inc.