MATLAB: Checking the variable for specific string

if statementstrings

Very new to Matlab. I need to give 'high' or 'low' in one function's input as shown below. How can I make sure that the variable only accept 'high' or 'low'? If anything else, then there will be an error like 'filter type error'.
Using code bellow, gives error even with 'high' and 'low' input.
Thanks!
function [Y] = butter2filtfilt(x, Fs, Fcutoff, Type)
if Type~= "high" || Type~= "low"
error ('Filter type error')
end
end
>> LF = butter2filtfilt(ecg, 257, 0.15, 'low');
Error using butter2filtfilt (line 6)
Filter type error

Best Answer

function [Y] = butter2filtfilt(x, Fs, Fcutoff, Type)
if ~ismember(Type,{'high','low'})
error ('Filter type error')
end
end
Related Question