Add String to Matlab Plot Annotation

22 次查看(过去 30 天)
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');

采纳的回答

Chunru
Chunru 2021-7-26
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');

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by