- want-to-have-m-function-in-m-script
- do-not-want-to-have-m-function-in-m-script
- don-t-care-to-have-m-function-in-m-script
subfunction in script
조회 수: 10 (최근 30일)
이전 댓글 표시
can one not use subfunction in script? Here is my attempt:
phrasemat=char('Hello','how are you', 'How is it going?', 'what is up?')
[r c]=size(phrasemat)
for i=1:r
howmany=countblanks(phrasemat(1,:));
fprintf('Phrase %d had %d blanks\n',i,howmany)
end
function num=countblanks(phrase)
num=length(strfind(strtrim(phrase),'');
end
댓글 수: 0
채택된 답변
Jan
2011년 10월 21일
편집: Jan
2018년 9월 13일
No, subfunctions in scripts are not allowed.
This has been discussed repeatedly. See:
[EDITED] Since R2016b you can define subfunctions in scripts also: https://www.mathworks.com/help/matlab/matlab_prog/local-functions-in-scripts.html
댓글 수: 0
추가 답변 (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!