I have made different functions as separate .m files and i want to include or call all these functions or .m files in my main .m file please any help?
조회 수: 15 (최근 30일)
이전 댓글 표시
I have made different functions as separate .m files and i want to include or call all these functions or .m files in my main .m file please any help? Walter the link you referred contains good code with many functions so how all these functions i include in my code or call in order to use its functtionality
채택된 답변
Stephen23
2016년 1월 20일
편집: Stephen23
2016년 1월 20일
Make sure that:
- the Mfiles are on your MATLAB search path, or are in the current directory.
- the function names the same as the Mfile name.
Then you can simply call the function from any script or function, just like you would any other function. It really is that simple.
Here is an example:
function out = myfun(x,y)
out = x^2 - y^3;
end
and I save this using the filename myfun.m, then I can call it like this, from any other function or script:
a = 1;
b = 2;
val = myfun(a,b)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!