MATLAB: Display Value in Text Box

text boxvalue

I am trying to display the value of a in a text box.
a=trapz(cP6-cP7);
str='Area Swept: %d';
annotation('textbox',[0.3 0.5 0.3 0.3],'String',str,'FitBoxToText','on');

Best Answer

You need to transform your value to text using either sprintf or num2str:
a=trapz(cP6-cP7);
str=sprintf('Area Swept: %d',a);
annotation('textbox',[0.3 0.5 0.3 0.3],'String',str,'FitBoxToText','on');