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 件のコメント
per isakson
2015 年 1 月 9 日
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
回答 (1 件)
Image Analyst
2015 年 1 月 9 日
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 件のコメント
Image Analyst
2015 年 1 月 9 日
You can also make a "method" of D that takes the "reports" properties of other objects and does something with them.
カテゴリ
ヘルプ センター および File Exchange で Properties についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!