Add String to Matlab Plot Annotation

24 visualizzazioni (ultimi 30 giorni)
david crowley
david crowley il 26 Lug 2021
Risposto: Chunru il 26 Lug 2021
I am trying to add an annotation to a plot that uses a variable from the workspace. I have used the below code, but the only output I get is 'Pf Size:'
Can someone please assist with the syntax?
dim = [.2 .5 .3 .3];
str = ('Pf Size:' num2str(pfSize));
annotation('textbox',dim,'String',str,'FitBoxToText','on');

Risposta accettata

Chunru
Chunru il 26 Lug 2021
pfSize = 2;
dim = [.2 .5 .3 .3];
str = ['Pf Size:' num2str(pfSize)]; % use [] instead of ()
plot(rand(10,1))
annotation('textbox',dim,'String',str,'FitBoxToText','on');

Più risposte (0)

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by