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

조회 수: 9 (최근 30일)
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Construct 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