Access to class members
Show older comments
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 Comments
Rik
on 6 Aug 2020
I'm on mobile so I can't test your code, but it looks like a constructor is missing.
kanuri venkata mohana
on 10 Aug 2020
Deepak Gupta
on 10 Aug 2020
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
on 10 Aug 2020
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
on 10 Aug 2020
kanuri venkata mohana
on 10 Aug 2020
Steven Lord
on 11 Aug 2020
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.
Accepted Answer
More Answers (0)
Categories
Find more on Construct and Work with Object Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!