Protected External Methods

조회 수: 13 (최근 30일)
David Kim
David Kim 2011년 5월 20일
As a coding standard, our lab uses external methods as a way of maintaining our modular code. However, I've found that MATLAB doesn't have a way to make the Access for external methods protected. I've found that I can make external methods private by adding a /private/ folder to the class folder, so I was wondering if there was a 'protected' equivalent.
  댓글 수: 2
Andrew Newell
Andrew Newell 2011년 5월 20일
I'm not sure what you mean by external. Is that the same as static?
David Kim
David Kim 2011년 5월 25일
External methods are methods that are contained in their own .m files within the class folder. It was how MATLAB did it before the new OOP was introduced. It's still supported, but we'd like to transition to actual OOP principles, such as "protected" inheritance methods.

댓글을 달려면 로그인하십시오.

채택된 답변

Daniel Shub
Daniel Shub 2011년 5월 20일
http://www.mathworks.com/help/techdoc/matlab_oop/brqy3km-14.html#brqy3km-15 under "Specify Method Attributes in classdef File" ...
Basically, inside the class definition create a methods block with properties Acess = protected. Inside that block add the function footprint.
methods (Access = protected)
[a,b,c]=protectedmethod(x,y,z);
end
Then create a seperate m file in the root class directory named protectedmethod with the header
function [d,e,f]=protectedmethod(u,v,w)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Model Protection에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by