Re: Filename Problem
- From: Peter Boettcher <boettcher@xxxxxxxxxx>
- Date: Wed, 19 Apr 2006 08:37:15 -0400
nick <nickbaker@xxxxxxxxxxx> writes:
Simple question I think but, the following code asks for a file to be
specified which is then opened and loaded into the matlab workspace.
Is it possible to continue the code by plotting whatever is in
"filename". Im trying to open a file called 'list.mat'an array, but
it does not seem you can plot it without using its real name.
[filename, pathname] = uigetfile( ...
{'*.m;*.fig;*.mat;*.mdl','MATLAB Files (*.m,*.fig,*.mat,*.mdl)';
'*.m', 'M-files (*.m)'; ...
'*.fig','Figures (*.fig)'; ...
'*.mat','MAT-files (*.mat)'; ...
'*.mdl','Models (*.mdl)'; ...
'*.*', 'All Files (*.*)'}, ...
'Pick a file');
load (filename);
The easiest thing is to specify an output argument for load:
data = load(filename)
Now a MAT file may contain many variables, so you have to figure out
what to do about that. If you always want the first one, you can do:
% List of all fields of data (all variables in the file)
f = fieldnames(data);
% Extract the contents of the first one with a dynamic
% field reference
y = data.(f{1});
--
Peter Boettcher <boettcher@xxxxxxxxxx>
MIT Lincoln Laboratory
MATLAB FAQ: http://www.mit.edu/~pwb/cssm/
.
- References:
- Filename Problem
- From: nick
- Filename Problem
- Prev by Date: Re: how to access cell array as a numeric
- Next by Date: Inserting sequence data object to DICOM file
- Previous by thread: Filename Problem
- Next by thread: FFT of time-varying 2D position data
- Index(es):
Relevant Pages
|