Be the first to rate this file! 5 Downloads (last 30 days) File Size: 5.09 KB File ID: #10003

globalLoad.m

by Gerald Dalley

 

15 Feb 2006 (Updated 21 Feb 2006)

Loads a .mat file's variables into the global namespace

| Watch this File

File Information
Description

%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;
% end
% 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.
%
%GLOBALLOAD(FNAME)
% 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');
% disp(bar);
%

MATLAB release MATLAB 7.0.4 (R14SP2)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
21 Feb 2006

Removed boilerplate copyright.

Tag Activity for this File
Tag Applied By Date/Time
global load persistent save Gerald Dalley 22 Oct 2008 08:15:54

Contact us at files@mathworks.com