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

3 views (last 30 days)
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.

Answers (1)

Stephen23
Stephen23 on 23 Apr 2015
Edited: Stephen23 on 23 Apr 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 Comments
Xie Ya
Xie Ya on 23 Apr 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 on 23 Apr 2015
Edited: Stephen23 on 24 Apr 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.

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!