How do I run a command only if certain characters exist in a string
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Workspace Variables and MAT Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!