How to input a text variable in a plot title?

Hello, I have 100 plots to do but I have to change the title and the labels every time. Is it possible to input a value with the name of the title and the labels in order to be set in all plots without doing it by my own? Thank you in advance for your response!

 Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 13 Jul. 2018

0 Stimmen

Is this what you want?
title('plot title')
TitleText='second plot';
title(TitleText)

3 Kommentare

Ilias Tripodis
Ilias Tripodis am 13 Jul. 2018
Bearbeitet: Ilias Tripodis am 13 Jul. 2018
It is close enough! I want something like that:
x='amplitude';
title('%d vs Time',x)
I want to change the x every time i run my code!
Thank you!
Fangjun Jiang
Fangjun Jiang am 13 Jul. 2018
use sprintf(), use %d for numerical data, use %s for string
title(sprintf('%s vs Time',x))
Ilias Tripodis
Ilias Tripodis am 13 Jul. 2018
Bearbeitet: Ilias Tripodis am 13 Jul. 2018
It definitely works! Thank you very much!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by