Info
此问题已关闭。 请重新打开它进行编辑或回答。
Accessing data within astructure
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I am trying to access data from a part of a structure, which I have not implemented myself.
It looks like:
>> whos
Name Size Bytes Class Attributes
anotace 1x1 2648 struct
then:
anotace.borders
ans =
1x5 struct array with fields:
Y
H
type
>> anotace.borders.Y
ans =
106.0000 106.0000 164.5000 164.5000
685.2500 733.2500 733.2500 685.2500
ans =
368.5000 368.5000 440.5000 440.5000
604.2500 661.2500 661.2500 604.2500
ans =
351.5448 351.5448 421.5945 421.5945
461.3955 521.8930 521.8930 461.3955
ans =
356.3209 356.3209 432.7388 432.7388
306.9677 369.0572 369.0572 306.9677
ans =
337.2164 337.2164 423.1866 423.1866
192.3408 252.8383 252.8383 192.3408
I would like to access anotace.borders.Y and use its data as an array of arrays(each ans as one array). When I try to assign its value I only get the first ans into my new variable.
Thanks for help.
0 个评论
回答(2 个)
Amit
2014-1-19
you can access each array as anotace.borders.Y{i} where i is the i'th array in the structure.
4 个评论
Jan
2014-1-19
@Amit: Using EVAL to create variables dynamically is a very bad programming practize and there is always a better solution.
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!