一、将字符串转换成大写字母或小写字母(不用upper和lower).
1、字符串为‘abcd’
str = 'abcd';
for i = 1:length(str)
str1(i) = str(i) - 32;
end
s=char(str1)
2、字符串为’Hello 2020’
转大写:
s='Hello 2020'
s1=char(s-32*(s>=97&s<=122))
% s1=char(s-32*(s>='A'&s<='Z'))
转小写:
s='Hello 2020'
s2=char(s+32*(s>=65&s<=90))
二、upper和lower将字符串转换成大写字母或小写字母
A='aBc';
upper(A)
A='aBc';
lower(A)