How do I change the name of a file inputted to a function in MATLAB?

1 回表示 (過去 30 日間)
Samyukta Ramnath
Samyukta Ramnath 2013 年 6 月 13 日
I want to input a text file to a function, and after running the function, want to change the filename to a specific thing, depending on the results of the function. For example, if the function classifies the folder as belonging to History, I want to rename the text document to History1, if another test file gets classified as belonging to topic history, I want it to be renamed as History2, and so on, and placed in a specific folder.
  2 件のコメント
Jan
Jan 2013 年 6 月 14 日
Ok. What have you tried and which problems have occurred?
Samyukta Ramnath
Samyukta Ramnath 2013 年 6 月 14 日
I did use the copyfile and thought that I could use a persistent variable, so that each time the function runs, if the file was classified as History, then the persistent variable var_hist would be incremented. But I don't know how to save the name as History1, History2 etc. by incrementing the number every time it is classified as History.
if true
if Prob_Hist(1) == max(Prob)
disp('History');
var_hist = var_hist + 1;
copyfile('InputFile.txt','new_name.txt');
end
end

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2013 年 6 月 14 日

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Data Preparation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by