what does this line of do

1 view (last 30 days)
THE GUY WITH WORK TO DO
THE GUY WITH WORK TO DO on 1 Oct 2022
Commented: Walter Roberson on 3 Oct 2022
what does this code line do generally
M.surfaceArea = FV.totalArea;

Answers (1)

Walter Roberson
Walter Roberson on 1 Oct 2022
FV might be a structure that has a field named totalArea and the content of the field is to be copied to a destination.
Or possibly FV is an object of some class that defines a property or method named totalArea whose content is to be extracted to be copied to a destination; this could potentially involve doing work to calculate the total area of whatever is being represented.
The destination might be a property name of an object named M and the source value is to be copied to the object property. If so that might also trigger other work.
Or the destination M might be a structure with a field named surfaceArea whose content is to be overwritten. Or perhaps M is a structure that does not have an existing field with that name and the field is to be created and set to the source value.
It is also possible that the variable M does not exist at that point. If so then M would be created as a structure and the field surfaceArea would be created in the structure and set to the source value.
With just that one line we cannot give you a definite answer about whether the source on the right is a structure or an object, and with just the one line we cannot give you a definite answer about whether the destination on the left is a structure or an object.
  2 Comments
Walter Roberson
Walter Roberson on 3 Oct 2022
This turns out to be a single line extracted without context from https://www.mathworks.com/matlabcentral/answers/1814960-i-am-unable-to-understand-this-metrics-code-completely-please-help#answer_1065475
FV turns out to be an object, but we cannot say whether the total area is a property or a method.
The destination being written to turns out to be a property of an object.

Sign in to comment.

Categories

Find more on Operators and Elementary Operations 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!

Translated by