Move diary in file to newfolder

Hi.I export my output file to diary file.I want each time i run the code, matlab move diary file to a newfolder and rename the folder name to date and time of running code.how can i do?

 Respuesta aceptada

Peter O
Peter O el 6 de Jul. de 2021
Hi Armin,
Try this at the start of your code. You may need to ensure the path exists before creating the diary file. You should get an error if that's the case, use mkdir for the path.
mypath = 'diaries'
myfile = "mydiary_" + datestr(now,30) + ".txt"
filepath = fullfile(mypath, myfile)
diary(filepath)
% Print location of diaryfile
get(0,'DiaryFile')

8 comentarios

armin m
armin m el 6 de Jul. de 2021
Hi peter Thank you for your help.these 2 pic show the errors how can fix them?
Peter O
Peter O el 6 de Jul. de 2021
That's a quick fix. I'm guessing this is an older version of MATLAB from before they introduced strings. Try this: myfile = ['mydiary_', datestr(now, 30), '.txt']
armin m
armin m el 6 de Jul. de 2021
Thank you very much. It works. Is it possible to change font color of txt file?
Peter O
Peter O el 6 de Jul. de 2021
If you're opening it from Notepad: Format -> Font...
If you're within MATLAB, a text file will be treated like plain text. You can change the font/color for all editor files by going to Preferences->Colors.
armin m
armin m el 6 de Jul. de 2021
I have a matrix which i want to change one row of it to different color.
armin m
armin m el 6 de Jul. de 2021
I want have a code to do it automatucally.
Peter O
Peter O el 6 de Jul. de 2021
Not possible, unfortunately.
armin m
armin m el 6 de Jul. de 2021
Thank you alot

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Entering Commands en Centro de ayuda y File Exchange.

Preguntada:

el 6 de Jul. de 2021

Comentada:

el 6 de Jul. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by