Convert folder of functions - > Class folder
이전 댓글 표시
I have a folder full of functions and I would like to turn it into a class folder.
example: my folder of function has
func1.m
func2.m
func3.m
Currently I have dumped all the function signatures into a class method.
classdef myclassname<handle
% properties blah blah
% constructor here etc etc
methods (Static)
func1()
func2()
func3()
end
end
end
These functions call out other functions and I would have to create dot notation each time, ex:
function func1()
myclassname.func2
myclassname.func3
end
Now, I have more than 50 functions. I dont want to keep looking around to find out where I need to put the class handle and dot wherever a function within myclass folder is being called -- Is there something more efficient that will do all of that for me?
댓글 수: 7
Steven Lord
2019년 2월 7일
I have a folder full of functions and I would like to turn it into a class folder.
Can you say a little more about why you want to turn the folder full of functions into a class? What benefit do you hope to gain by doing so?
Walter Roberson
2019년 2월 7일
perhaps you should consider creating a package instead of a class and then import the package .
Matt J
2019년 2월 7일
I don't think packaging the files will help, unfortunately. Packaged functions still need to refer to each other using package.func syntax.
Guillaume
2019년 2월 7일
Yes, you still need to refer to the prepend the name of the package, even within the package scope. A very annoying feature of matlab.
However, in this case, you could just add an import packagename.* to the start of each function. Less painful than trying to locate each function call.
Kevin Phung
2019년 2월 7일
편집: Kevin Phung
2019년 2월 7일
Steven Lord
2019년 2월 7일
Kevin Phung
2019년 2월 7일
편집: Kevin Phung
2019년 2월 7일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Argument Definitions에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!