How to use objects of one class in the methods of another class as input?

10 ビュー (過去 30 日間)
kanuri venkata mohana
kanuri venkata mohana 2020 年 7 月 28 日
コメント済み: Matt J 2020 年 7 月 28 日
Hi,
How can I use object of one class in another class?
Example
classdef clcore
properties
dcs
wcs
end
methods
function objc = clcore (dcs, wcs)
objc.dcs = dcs;
objc.wcs = wcs
end
end
end
the object of clcore is objc
objc = clcore
Now the same object i want to use it in my clMec
classdef clMec
properties
mecmode
mec
end
end
I want to give objc as input to clmec since i have many calculations using the parameters in objcore. So there is anyway in doing it.
Thank you

採用された回答

Matt J
Matt J 2020 年 7 月 28 日
編集済み: Matt J 2020 年 7 月 28 日
objc is a Matlab variable like any other, and therefore you can give it as input to a function or class method just like any other. There is no special technique.
  2 件のコメント
kanuri venkata mohana
kanuri venkata mohana 2020 年 7 月 28 日
thankyou for your reply Matt. May i know how to pass the field values from superclass to subclass. not the properties but the values of it.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConstruct and Work with Object Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by