Make a function that returns its own character count - MATLAB Cody - MATLAB Central

Problem 242. Make a function that returns its own character count

Difficulty:Rate
Write a function that returns a 128 element vector with an accurate inventory of the ASCII characters in its own function file. The test suite uses textscan to verify that your function returns the exact same census.
file = textscan(fid,'%c','CommentStyle','%','Whitespace','')
filetext = file{1};
texthist = histc(filetext,1:128);
Newlines are suppressed by this approach, so you may assume the counts for ASCII 10 and 13 are zero.
Special Note: The characters associated with ASCII values 33-41 are not allowed in your function. For clarity, these are
33 !
34 "
35 #
36 $
37 %
38 &
39 '
40 (
41 )

Solution Stats

15.56% Correct | 84.44% Incorrect
Last Solution submitted on May 01, 2025

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
4
6
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Problem Recent Solvers30

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page