isalpha

版本 1.0.0 (7.9 KB) 作者: Anmol Pardeshi
check if variable is alphabet
11.0 次下载
更新时间 2020/7/9

查看许可证

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

引用格式

Anmol Pardeshi (2024). isalpha (https://www.mathworks.com/matlabcentral/fileexchange/77966-isalpha), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2020a
兼容任何版本
平台兼容性
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.0