Object-Object Interactions: Passing information about one object to another

I am writing a program that creates objects (let us call them A, B, C, and D) and then passes information about three of the objects to the last object (e.g. reports properties of A, B, and C to object D). D then performs computations on the information that it receives from A, B, and C. Does MATLAB have some existing code element that would facilitate passing information about certain objects to other objects? I would rather not make the information about A, B, and C a property of object D.
Any advice would be much appreciated! Many thanks.

1 commentaire

You provide little context. Didn't you search the documentation or don't you think that the described approaches are good enough?
Please eleborate your question

Connectez-vous pour commenter.

Réponses (1)

Yes. It's called a function . Pass the "reports" property of A, B, and C into a function, and also pass in the entire D object.
output = ProcessObjects(A.reports, B.reports, C.reports, D);
Then define the function
function output = ProcessObjects(report1, report2, report3, D)
% Then do something with the inputs and create an output
output = ..... whatever......

1 commentaire

You can also make a "method" of D that takes the "reports" properties of other objects and does something with them.

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by