access struct data using 'fileName' given by U = load([filePath fileName])
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
TAB
2012-3-29
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.
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!