matlab正则表达式if语句

E.C*_*oss 1 regex matlab if-statement

我想让matlab接受用户输入但接受两个字母的情况.例如,我有:

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
Run Code Online (Sandbox Code Playgroud)

if语句显然不起作用,但基本上我想接受小写或uppcase Y.最好的方法是什么?

Fra*_*urt 5

使用下部上部的功能.例如:

if (lower(reply) == 'y')
Run Code Online (Sandbox Code Playgroud)

或者,strcmpi将不区分大小写地比较字符串.例如:

if (strcmpi(reply, 'y'))
Run Code Online (Sandbox Code Playgroud)