结构中的八度结构
Octave structure within a structure
我想在 Octave 的结构中创建结构。看起来像
class =
{
grade = Graduate
studentname = John
university = St. Jones
student=
{
name=John
age=18
address=Houston
}
}
为了在我写下的结构中实现这个结构
>> class.grade='graduate';
>> class.studentname='John';
>> class.university='St.Jones';
>> student.name='John';
>> student.age=18;
>> student.address='Houston';
>>student.class=struct %To create structure within a structure
我得到了这个输出:
student =
scalar structure containing the fields:
name = John
age = 18
address = Houstan
class =
scalar structure containing the fields:
我不明白为什么class结构在这里是空的?如果我尝试 运行 这样的代码也是如此
>> class.student=struct
输出为
class =
scalar structure containing the fields:
grade = graduate
studentname = John
university = St.Jones
student =
scalar structure containing the fields:
请帮我解决问题。
所以,从我的角度来看,有两种可能。
要么设置您的(子)结构 student
,然后再设置 class.student = student
。通过这种方式,class
中的字段 student
隐含地成为一个(子)结构。代码将是这样的:
class.grade = 'graduate';
class.studentname = 'John';
class.university = 'St.Jones';
student.name = 'John';
student.age = 18;
student.address = 'Houston';
class.student = student
class =
scalar structure containing the fields:
grade = graduate
studentname = John
university = St.Jones
student =
scalar structure containing the fields:
name = John
age = 18
address = Houston
或者您可以在开始时使用嵌套结构,如下所示:
class.grade = 'graduate';
class.studentname = 'John';
class.university = 'St.Jones';
class.student.name = 'John';
class.student.age = 18;
class.student.address = 'Houston';
class
class =
scalar structure containing the fields:
grade = graduate
studentname = John
university = St.Jones
student =
scalar structure containing the fields:
name = John
age = 18
address = Houston
同样,class
中的字段 student
也隐含地成为一个(子)结构。
希望对您有所帮助!
我想在 Octave 的结构中创建结构。看起来像
class =
{
grade = Graduate
studentname = John
university = St. Jones
student=
{
name=John
age=18
address=Houston
}
}
为了在我写下的结构中实现这个结构
>> class.grade='graduate';
>> class.studentname='John';
>> class.university='St.Jones';
>> student.name='John';
>> student.age=18;
>> student.address='Houston';
>>student.class=struct %To create structure within a structure
我得到了这个输出:
student =
scalar structure containing the fields:
name = John
age = 18
address = Houstan
class =
scalar structure containing the fields:
我不明白为什么class结构在这里是空的?如果我尝试 运行 这样的代码也是如此
>> class.student=struct
输出为
class =
scalar structure containing the fields:
grade = graduate
studentname = John
university = St.Jones
student =
scalar structure containing the fields:
请帮我解决问题。
所以,从我的角度来看,有两种可能。
要么设置您的(子)结构 student
,然后再设置 class.student = student
。通过这种方式,class
中的字段 student
隐含地成为一个(子)结构。代码将是这样的:
class.grade = 'graduate';
class.studentname = 'John';
class.university = 'St.Jones';
student.name = 'John';
student.age = 18;
student.address = 'Houston';
class.student = student
class =
scalar structure containing the fields:
grade = graduate
studentname = John
university = St.Jones
student =
scalar structure containing the fields:
name = John
age = 18
address = Houston
或者您可以在开始时使用嵌套结构,如下所示:
class.grade = 'graduate';
class.studentname = 'John';
class.university = 'St.Jones';
class.student.name = 'John';
class.student.age = 18;
class.student.address = 'Houston';
class
class =
scalar structure containing the fields:
grade = graduate
studentname = John
university = St.Jones
student =
scalar structure containing the fields:
name = John
age = 18
address = Houston
同样,class
中的字段 student
也隐含地成为一个(子)结构。
希望对您有所帮助!