MATLAB: Delete last 4 characters in a string variable

MATLABstringsvariables

In my script, I have used the 'uigetfile' function to acquire the FileName and PathName of a .txt file in order to read it. Later in the script I need to parse that file and write the parsed information to another .txt file. I want to name the file I am writing to to a similar name as the file I'm reading from. Example:
Open/read from: C:\Documents and Settings\blah\TestFile.txt
Write/parsed to: C:\Documents and Settings\blah\TestFileParsed.txt
Basically how do I delete the last four characters in a string variable? Thanks for the help!

Best Answer

For example:
S = 'Mystringname.txt'
S = S(1:end-4)