MATLAB Answers

AA
0

displaying date as title of figure

Asked by AA
on 26 Oct 2017
Latest activity Answered by Fangjun Jiang
on 26 Oct 2017
hi, i want to display a date as title of a figure.
caption = sprintf(' %.3f', datestr(q{:,1}(1,1)));
This q cell array contains a dateserial number. When I display it as datestr then I get random numbers but not the actual date. How can I change that?

  0 Comments

Sign in to comment.

2 Answers

Answer by Walter Roberson
on 26 Oct 2017
 Accepted Answer

caption = datestr(q{:,1}(1,1));
It is already text: you do not need to format it.

  0 Comments

Sign in to comment.


Answer by Fangjun Jiang
on 26 Oct 2017

The output of datestr() is already a string, so you don't need to use sprintf() anymore. Use datastr() directly.
If you still need to use sprintf(), then use '%s' instead of '%.3f'.

  0 Comments

Sign in to comment.