Info

This question is closed. Reopen it to edit or answer.

Text header in file

1 view (last 30 days)
L3munoz
L3munoz on 16 Mar 2012
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi everybody,
I wanted to write a info header in a txt file from Matlab. I wanted to include author information, date, and some details of the file, something like this
/------------------------------------------------------- /Journal File for Gambit 2.4.6, Database 2.4.4, intx86 SP2007051421 /Identifier: Geometry2 /Ph.D Project. 'Aerodynamic Optimization of ICE2 High-speed Train Nose Using a Genetic Algorithm and Metamodels' /Miguel Martin (<mailto:lehouth@upm.es lehouth@upm.es>) Universidad Politecnica de Madrid, Spain /Date: 16/03/2012 /-------------------------------------
The point is that I wanted all to be included in some kind of box made of /----- ... ---/, so at the beginning of each row there is a /, and at the end of them once again, but this last character should appear not just after the text but in the same column as the largest string. My first idea was to create long strings with spaces and ending with a / character, but this is not cool at all, is there any way to do it in a smarter way?
(this is what i did
infoTitle = '/Journal File for Gambit 2.4.6, Database 2.4.4, intx86 SP2007051421 /'; cs = ''''; infoProject = ['/Ph.D Project. ' cs 'Aerodynamic Optimization of ICE2 High-speed Train Nose Using a Genetic Algorithm and Metamodels' cs]; fprintf(fid, '%s \n%s, infoTitle)
Thanks in advance
L3munoz
  1 Comment
Jan
Jan on 16 Mar 2012
Please format the code and the text as explained in the "Markup help" link on this page.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!