问题
Why is one ans removed when I assign y? I want to return the two descriptions.
x = rmi('get',gcs)
x =
2x1 struct array with fields:
doc
id
linked
description
keywords
reqsys
>> x.description
ans =
FirstReq
ans =
SecondRec
>> y = x.description
y =
FirstReq
>> y
y =
FirstReq
回答1:
You probably need to use the {}:
>> x.description
ans = FirstReq
ans = SecondRec
>> y = {x.description}
y =
{
[1,1] = FirstReq
[1,2] = SecondRec
}
You can then index into y using either () (output will be a cell array) or {} (output will be whatever the data type of the description field is):
>> y(1)
ans =
{
[1,1] = FirstReq
}
>> y{1}
ans = FirstReq
Note: I am using Octave, not MATLAB, but it should still apply.
来源:https://stackoverflow.com/questions/17811746/why-is-one-ans-removed-when-assigning-simulink-matlab