what is real filed from the header ?

2 views (last 30 days)
Kishan Paladiya
Kishan Paladiya on 2 Jul 2021
Commented: Kishan Paladiya on 3 Jul 2021
What is the meaning of "init a struct with any real field from the header" ?
  7 Comments
dpb
dpb on 2 Jul 2021
Edited: dpb on 2 Jul 2021
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"
Kishan Paladiya
Kishan Paladiya on 3 Jul 2021
Thank you so much, that's what I want. I appreciate and satisfy with this answer.

Sign in to comment.

Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!