Borrar filtros
Borrar filtros

How can I create dynamic session title when I am publish my code

4 visualizaciones (últimos 30 días)
Xie Ya
Xie Ya el 23 de Abr. de 2015
Editada: Stephen23 el 24 de Abr. de 2015
The question is during a for-loop, I want to create the dynamic session title during the loop. For example
for i = 10
%%the current loop is i % I want to generate this session title dynamically
run the code;
end
Because I have lots of figures during the codes, so I want to create more links in the context so I can link to the figures more quick.
Thanks.

Respuestas (1)

Stephen23
Stephen23 el 23 de Abr. de 2015
Editada: Stephen23 el 23 de Abr. de 2015
It is not very clear what you want to do, but perhaps you are looking to convert a numeric to string? In which case you could use sprintf, or int2str or one of the other number->string conversions functions.
for k = 1:10
sprintf('This is loop number %d',k)
end
  2 comentarios
Xie Ya
Xie Ya el 23 de Abr. de 2015
Thanks for you answering, but this is not the solution for my problem.
Then you publish your codes to html file, the first part part is the content. By just clicking the title in the content, I can go to the chapter I want.
As far as I know, I can add that with %% with comments manually.I want to know how to add the content dynamically.
Stephen23
Stephen23 el 23 de Abr. de 2015
Editada: Stephen23 el 24 de Abr. de 2015
So you wish to change comments during code publishing. As far as I am aware code comments are considered to be completely static, and cannot be defined dynamically. Even the LaTeX and HTML markup are interpreted "literally", and do not seem to allow for the inclusion of MATLAB values.
MATLAB's code publishing markup is clearly documented. Depending on what you want to do you might be able to use one of the formatting options available, including numbered lists, hyperlinks, etc.
You might be able to use the include syntax, and write the file dynamically... but this would be a bit of a hack job.
If none of these work, then you will have to create a simple string as per my original answer.

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by