Re: Filename Problem



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/
.



Relevant Pages

  • Re: Reporting Services and Excel
    ... Once again Keith, your advised has helped me tremendously, Thanks!!..In terms ... of the name of the file, I noticed that you can specify a filename if you are ... saving the report to a fileshare directory but you cannot specify a filename ...
    (microsoft.public.sqlserver.server)
  • Re: Secure C library - fopentmp_s (a usable secure create and open named temporary file)
    ... I would like to be able to specify all three. ... The filename is then generated by filling the remaining of fname. ... Although this specification would allow many different implementations, the drawback is that it assumes that the initial portion of a filename has some useful interpretation, like directory names in POSIX and Windows. ... Another possibility would be to add a template parameter which specifies how the filename is to be constructed. ...
    (comp.std.c)
  • Problem with WQL query [CIM_DataFile]:Property-combinations fail
    ... My only problem is, if I specify some property-combinations, ... the FileName, but not the extension, it works also. ... if I specify drive, path, FileName and Extension together. ...
    (microsoft.public.win32.programmer.wmi)
  • File Upload - ValidationExpression (ASP.NET). Please help!!!
    ... "You must specify the file location and the filename must follow this ... Do I need to put it in ValidationExpression? ...
    (microsoft.public.dotnet.framework.aspnet)
  • Filename Problem
    ... specified which is then opened and loaded into the matlab workspace. ... [filename, pathname] ... = uigetfile(... ... load; ...
    (comp.soft-sys.matlab)