How can I add variables on the plot title

10 Ansichten (letzte 30 Tage)
J Kwon
J Kwon am 28 Aug. 2022
Kommentiert: Abderrahim. B am 28 Aug. 2022
In the code, I use for loop to change my variables(that means the time variation) from 1 to 100.
And I want to add variables on my title to express how the time goes on.
How can I do that thing.
Because I use Matlab 2014b, I can't use any brandnew functions... so I have difficulties.

Akzeptierte Antwort

Abderrahim. B
Abderrahim. B am 28 Aug. 2022
Pass the for loop index to num2str function then pass this to title. Something like this:
time = 0:1/100:1-1/100 ;
for ii = 1:length(time)
plot( time, ii*time )
title("var" + num2str(ii))
Hope this helps
  2 Kommentare
Abderrahim. B
Abderrahim. B am 28 Aug. 2022
My pleasure !

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)


Find more on Loops and Conditional Statements in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by