access struct data using 'fileName' given by U = load([filePath fileName])
5 views (last 30 days)
Show older comments
Hi,
thanks in advance.
I load a mat file called, for example, bending0001.mat using:
%------------------
[fileName filePath] = uigetfile('*.mat', 'Select data file', '.');
if filePath==0, error('None selected!'); end
U = load([filePath fileName])
%------------------
I want to access the struct data without giving the file name, but using the U. That means:
- this way :)
length_ = length(U.Trajectories.Labeled.Data(6,:,:));
- not this way :(
length_ = length(bending0001.Trajectories.Labeled.Data(6,:,:));
what happens is that the higher struct field has the same name as the file, using this feature, I could open multiple files easier without typing the name at each access
thank you a lot,
Carolina
2 Comments
TAB
on 29 Mar 2012
Variables from the U=load('bending0001.mat') function will be collected in U and not in bending0001.
Please check your question. It is not clear.
Answers (1)
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!