MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   求助:双大括号与单大括号的区别! (https://www.labfans.com/bbs/showthread.php?t=3904)

wupeng0618 2008-07-14 18:40

求助:双大括号与单大括号的区别!
 
各位大哥,我刚学MATLAB,有些地方不懂!
a=struct('x',[1 2 ; 6 3],'str',{{'wupeng','huaqiao';[12 3 6;23 6 5],'yucong'}})与
a=struct('x',[1 2 ; 6 3],'str',{'wupeng','huaqiao';[12 3 6;23 6 5],'yucong'})的区别!!!
为什么输出结果不同?

remnant 2008-07-14 19:31

[QUOTE=wupeng0618;13771]各位大哥,我刚学MATLAB,有些地方不懂!
a=struct('x',[1 2 ; 6 3],'str',{{'wupeng','huaqiao';[12 3 6;23 6 5],'yucong'}})与
a=struct('x',[1 2 ; 6 3],'str',{'wupeng','hu...[/QUOTE]

第一句:
a=struct('x',[1 2 ; 6 3],'str',{{'wupeng','huaqiao';[12 3 6;23 6 5],'yucong'}})

该语句创建一个1x1结构体数组a,包括域 x 和 str。
其中,x域中仅有一个2x2 double矩阵;在str域中,为1个2x2 的cell,两重{{ }}就是将
'wupeng','huaqiao';[12 3 6;23 6 5],'yucong' 宣明为一个 2x2 cell的内容。

第二句:
a=struct('x',[1 2 ; 6 3],'str',{'wupeng','huaqiao';[12 3 6;23 6 5],'yucong'})

该语句创建了一个2x2结构体数组,同样包括域 x 和 str。
其中,x域中为2x2 double矩阵;而在str域中,为2x2的结构体,也就是说,这个构建
结构体的语句,单重括号表示其括起来的是'str'域内的一个结构体数组。


所有时间均为北京时间。现在的时间是 05:00

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.