Including a value inside an annotation
이전 댓글 표시
I am trying to include a number which changes inside a recurring annotation.
This works - the number 48 is hard-coded:
annotation('textbox',[0.42 0.864 0.1 0.1],'String','L. St. Lawrence - INCREASE IN ISI (n=48)','EdgeColor','none', 'FontSize',12,'Color','black','FontWeight','bold')
This does not (note the insertion of a number q, which has been pre-allocated a value of 48):
annotation(['textbox',[0.42 0.864 0.1 0.1],'String','L. St. Lawrence - INCREASE IN ISI (n=',num2str(q),')','EdgeColor','none','FontSize',12,'Color','black','FontWeight','bold'])
The error I get is:
Error using annotation
First argument must be a valid annotation type or a handle to a figure, uipanel, or uitab.
Thanks for helping!
채택된 답변
추가 답변 (1개)
Sulaymon Eshkabilov
2023년 10월 28일
편집: Sulaymon Eshkabilov
2023년 10월 28일
Here is the solution to this issue:
q = 48;
DIM = [0.42 0.864 0.1 0.1];
STR = strcat('L. St. Lawrence - INCREASE IN ISI (n= ', num2str(q), ' )');
annotation('textbox',DIM,'String',STR,'FitBoxToText','on','EdgeColor','none','FontSize',12,'Color','black','FontWeight','bold');
댓글 수: 3
Paul Barrette
2023년 10월 28일
Sulaymon Eshkabilov
2023년 10월 28일
Most welcome -sir!
Paul Barrette
2023년 10월 29일
카테고리
도움말 센터 및 File Exchange에서 Parallel Computing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!