MATLAB: File name manipulation strings I have a file name that takes the form: S_1_X_Y where X can be an integer between 1-16, and Y is a letter a,b,c,d. I want to be able to just replace the number X by a user defined value. any help greatly appreciated. Thanks Best Answer X = 1;Y = 'a';sprintf('S_1_%d_%s',X,Y)EDITstr = 'S_1_6_a'x = 3;regexprep(str,'(_)\d+(_[abcd])', ['$1' sprintf('%d',x) '$2'])ans =S_1_3_a Related SolutionsMATLAB: How to display result from solve iwant = double(S) MATLAB: Using num2str to name a graph in plot try: text(1,1, ['y = ' (num2str(a)) 'x^{' (num2str(n)) '}' ] ) Related QuestionLast few characters of a stringCan you find the error in this code that aims to sum the digits of a stringDoes NUM2STR not return the correct string format that I specifiedNum2str errorsSplit up file name into strings…
Best Answer