How to set the output file name same as input names but with an additional word
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Jaideep Cherakka Kesavan
il 27 Dic 2022
Commentato: Jaideep Cherakka Kesavan
il 29 Dic 2022
I have a few folders each with one .txt file. I load one file at a time using a Matlab GUI:
function load_data_callback(~,~,h)
[FileName, FilePath, FlagUp]=uigetfile({'*.txt'; '*.csv'; '*.xls'; '*.xlsx'; '*.*'}, 'Choose Tab-Delimited Data File');
and make the calculations. Then, the function makes an outputfile called 'NumberOfSpikesPerROI_JCK.csv' by using:
C = ([SeriesLabels;num2cell(SeriesData)]);
writecell(C,'NumberOfSpikesPerROI_JCK.csv')
I want to get the name of the outputfile based on the name of the input file.
For example, if the file name of the first file that I loaded is 'MyFirstFile', then, the output should be 'MyFirstFile_NumberOfSpikesPerROI_JCK.csv' and saved in the same folder (which is currently in Matlab path) as the input file.
Please suggest how to achieve this.
Thank you.
0 Commenti
Risposta accettata
the cyclist
il 27 Dic 2022
If I understand your code correctly, then you've got
FileName = 'MyFirstFile';
So, you could get your new filename as
newFileName = [FileName, '_NumberOfSpikesPerROI_JCK.csv'] % Use square brackets to concatenate character arrays
It's just a little bit trickier if your input filename is actually something like
FileName = 'MyFirstFile.csv'
and you are trying to insert the text in the middle. But, the principle is the same. Please clarify, if I have misunderstood your question.
2 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!