Statement of Matlab regex si
source link: https://www.codesd.com/item/statement-of-matlab-regex-si.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Statement of Matlab regex si
I want to have matlab take user input but accept both cases of a letter. For example I have:
function nothing = checkGC(gcfile)
if exist(gcfile)
reply = input('file exists, would you like to overwrite? [Y/N]: ', 's');
if (reply == [Yy])
display('You have chosen to overwrite!')
else
$ Do nothing
end
end
The if statement obviously doesn't work, but basically I want to accept a lowercase or uppcase Y. Whats the best way to do this?
Use the functions lower or upper. E.g.:
if (lower(reply) == 'y')
Alternatively, strcmpi will compare strings case-insensitively. E.g.:
if (strcmpi(reply, 'y'))
Related Articles
Using the switch statement to evaluate regex to javascript
How to compare the array to a number for the if statement in matlab
Replace the vector elements using the / if state in Matlab
Statement by Matlab while
if-elseif-else statement for MATLAB
How to use the 'if' statement in matlab?
Delimiter options with dlmwrite statements in matlab
Matlab regex: How to enter a folder name in path
Conditional statement about various regex and length of a python list
How to imitate negative statements on Qt regex?
How to extract the drbd state using grep / regex / cut / awk / sed etc.
Matlab: Regex to remove consecutive white space and punctuation
How do I compare numbers using if and / or statements in matlab?
MySQL: use REGEX to extract a string (select REGEX)
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK