Input: string or char variable ONLY
output: is the variable consists of alphabets only
process: While MATLAB has a function named isnumeric (input = double ; output = if the variable consists of numbers only)
and isletter (input = char ; ouptut = locations where alphabets are present are marked as 1 , else 0) but what if you want to know if the complete variable consists of alphabets only? i.e you do not necessarily want to deal with 1s and 0s on indexs of the variable. What is want to use it in an if condition?
Eg: if student_name=string("Jonas") and you want to know if all such student name entries are alphabets only.
Eg2: if patient_ID=string("Martha_021") and you want to know if the initial part consists of alphabets only and not numbers. This is common mistake in medical field (I have encountered this in huge datasets).
on both the above examples you can write a statement like:
if isalpha(this_name)
else
%throw error
end
Cite As
Anmol Pardeshi (2024). isalpha (https://www.mathworks.com/matlabcentral/fileexchange/77966-isalpha), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0 |
|