subfunction in script
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Problem-Based Optimization Setup in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!