Access to a structure value with the field path in a String form
Show older comments
Hi,
I don't know how to access to a specific array stored in a structure by using the field path stored in a String form. The following code shows my issue:
clear all;
clc;
Struct.a.b.c.d = [1 2 3; 4 5 6]; % Structure containing the Matrix
structString = 'a.b.c.d(:,1)'; % String with the desired path
Ideally, I would like to access to the matrix with something like:
value = Struct.(structString)
But it doesn't work...
Thanks in advance for your help!
Accepted Answer
More Answers (1)
Image Analyst
on 9 Aug 2015
Why are you trying to get a string involved in this at all? Why not just get the values directly from the structure:
value = Struct.a.b.c.d(:,1)
I just don't see any need to involve a string at all.
1 Comment
Rodolfo_H
on 10 Aug 2015
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!