Access to class members
古いコメントを表示
Hi guys,
I am having some problem in accessing the class members of one class to another class. I have checked in matlab documentation but i didn#t understood it weel. Could anyone help me in understanding it.
classdef clcore
properties(GetAccess=?clMec)
cpc
csc
end
properties(Dependent, GetAccess=?clMec)
ws
end
methods(GetAccess=?clMec)
function ws=get.ws(obj)
ws=obj.cpc+obj.csc;
end
end
end
classdef clMec
properties
Mecmode
end
methods
%
end
end
and in command window
objcore=clcore(1,2)
I knew the way i have done is wrong but my context is this. Could anyone explain me how to use this getaccess.
thankyou.
7 件のコメント
Rik
2020 年 8 月 6 日
I'm on mobile so I can't test your code, but it looks like a constructor is missing.
kanuri venkata mohana
2020 年 8 月 10 日
Deepak Gupta
2020 年 8 月 10 日
You have multiple classes in one file. In matlab, one class can be defined in one file.
I don't understand what is 'GetAccess=?' in your class.
When you are creating an object of the class, you are passing some arguments but your class doesn't have any constructors to handle these arguments.
Walter Roberson
2020 年 8 月 10 日
You do not appear to have a method named the same thing as your class, so you do not have any constructor for your classes. You also have no static methods for your classes, so you cannot be using the class as a framework to hold static methods. There is therefore no way to construct a member of your class, or to use any method in your class.
kanuri venkata mohana
2020 年 8 月 10 日
kanuri venkata mohana
2020 年 8 月 10 日
Steven Lord
2020 年 8 月 11 日
Show us a small example that is complete that shows the problem. We should be able to execute the example using your exact reproduction steps. This will help us understand where you're having difficulty.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File 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!
