Code to edit a file name?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello all,
I'm writing a program that calibrates various files. Part of the job I want it to do is to output a new file with the calibrated data. In doing so though I want to edit the original name for the name of the output file.
Matlab seems to have a rather robust string handling system, a bit more perhaps than I'm ready to deal with at the moment. I've found that I can use the "strcat" function to jam two strings together. This will likely lead to a filename.filextensionextratxt.fileextension. But at the moment its the best I can figure out.
Anyone handy out there know of a way to perhaps remove a set number of characters at the end of a string or perhaps a more elegant method?
Thanks for your time!
2 Kommentare
Fangjun Jiang
am 12 Jul. 2011
You need to provide an example of your file names and the expected pattern or new file names.
Akzeptierte Antwort
Ping
am 12 Jul. 2011
you can call [pathstr, name, ext] = fileparts(filename) to seperate filename and extension.
Weitere Antworten (2)
Sean de Wolski
am 12 Jul. 2011
string = 'hello world'
sm3 = string(1:end-3); %string removing three letters.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Environment and Settings finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!