what is real filed from the header ?
1 次查看(过去 30 天)
显示 更早的评论
What is the meaning of "init a struct with any real field from the header" ?
7 个评论
dpb
2021-7-2
编辑:dpb
2021-7-2
Well, the code simply creates a struct with the field 'speed' with a real value (happens to be zero), but by using a literal constant, the existence of any header field of that name is totally irrelevant -- so the comment doesn't appear to match the code on the micro basis, anyway (as, unfortunately, one finds often is true).
>> struct('speed',0)
ans =
struct with fields:
speed: 0
>>
In the larger context of the overall code it may have some relevance if there's later logic that compares that field to some header structure for which we have no reference, but that's again something that's not knowable simply from the code posted.
So it may well be there is a field 'speed' in some header somewhere and it may turn out that whether the specific field exists or not elsewhere is important, but it's totally immaterial as to the functioning of the above line in isolation.
Context is everything..."location, location, location!" as the mantra goes, and like "peephole" optimizations that try to fine tune code for performance by looking at individual pieces in isolation, trying to interpret overall intent by looking only at single instructions/lines of code is likely as not to miss the larger point in "not seeing the forest for the trees"
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!