Query data from 1xn struct
显示 更早的评论
Hi, I have a 1x3 struct just like below:
% Q(1)
Q(1).name='carrot';
Q(1).price=200;
Q(1).number=1000;
%Q(2)
Q(2).name='banana';
Q(2).price=200;
Q(2).number=2000;
%Q(3)
Q(3).name='apple';
Q(3).price=900;
Q(3).number=200;
How can I quickly query "price" of "banana" or "number" of "apple"?
Is there any shorcut beside manually gathering name to string array (Q.name returns scattering outputs)
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!