Access to class members
Mostra commenti meno recenti
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 Commenti
Rik
il 6 Ago 2020
I'm on mobile so I can't test your code, but it looks like a constructor is missing.
kanuri venkata mohana
il 10 Ago 2020
Deepak Gupta
il 10 Ago 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
il 10 Ago 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
il 10 Ago 2020
kanuri venkata mohana
il 10 Ago 2020
Steven Lord
il 11 Ago 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.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Construct and Work with Object Arrays in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
