%GLOBALLOAD(FNAME, VARNAME1, VARNAME2, ...)
% Loads a .mat file's variables into the global namespace, but only if at
% least one variable-to-be-loaded is zero-length. Example:
% globalLoad('foo.mat', 'bar', 'baz')
% is basically equivalent to:
% global bar baz;
% if (length(bar) == 0) || (length(baz) == 0)
% load foo.mat bar baz;
% This function is useful if you have very large static data structures that
% would be too expensive to load into memory every time they are needed and
% when it would not be practical to pass them in as parameters to functions
% that need them.
% Loads all variables from the .mat file into the global namespace.
%GLOBALLOAD(FNAME, ..., '-checksizes')
% Loads variables if any of their sizes do not match the size in the file.
% This is a stronger check than is normally made. This version is generally
% slower than the others because it must do a scan of the .mat file to read
% the variable sizes.
%In all cases, the global variables are defined in the caller's symbol
%table. For example, the following code is valid (assuming fooData.mat
%contains a variable bar):
% function foo
% globalLoad('fooData.mat', 'bar');
Gerald Dalley (2021). globalLoad.m (https://www.mathworks.com/matlabcentral/fileexchange/10003-globalload-m), MATLAB Central File Exchange. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!