MATLAB: How to run a command only if certain characters exist in a string

string find contains getfile

Hi
I'm trying to run a command that lets me open a file and then will run a process on that imported file depending on characters in the file name.
Say for example I open a file form a folder and then save that filepath as a string. I then want to run a process on it depending on the name of the file path.
The file names are TestMax, TestMin,TestMean
for i = int8(1:nUPSS)
[filename1, dir] = uigetfile('C:\Outputs','Select Trial');
load([dir filename1])
Therefore my trial name becomes either
filename1 = 'TrialMin.mat'
Or
filename1 = 'TrialMax.mat'
Or
filename1 = 'TrialMean.mat'
I then want to be able to run my next line of code depending on the characters in the string.
If filename1 contains Max...
do this
elseif filename1 contains Min...
do this
I hope this makes sense and any help would be much appreciated

Best Answer

Where fnm is the filename:
C = regexp(fnm,'M[a-z]+','once','match');
switch C{1}
case 'Min'
...
case 'Max'
...
case 'Mean'
...
otherwise
.... !!!
end
Note that it is highly recommended to always load into a variable (which happens to be a structure):
S = load(...);