![]() |
Matlab:结构中变量的名称
给定一个具有多个未知字段的函数的结构,如何获得每个字段的名称?
例如: s = struct; s.hello = 'world'; s.foo = 12; s.bar = [ 1 2 3 ]; 我想要s(1),s(2)和s(3)的名称。在这种情况下,我会得到“ hello”,“ foo”和“ bar”。 [B]回答:[/B] 您正在寻找[URL="http://www.mathworks.com/help/techdoc/ref/fieldnames.html"]FIELDNAMES[/URL] fieldnames(s) fn = 'hello' 'foo' 'bar' 请注意, fn是一个单元格数组,因此您将获得'foo'作为fn{2} [url=https://stackoverflow.com/questions/5419518]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 00:18。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.