- 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!