MATLAB: Highlighting (make bold or underline) an item in a cellstring to be used in an annotation

annotation;boldcellstring

Hi, I want to highlight by either underlining or making bold or different color only one cell string in the annotation:
In the code, newname is a string and the item I want highlighted.
dim = [0.4 0.1 0.2 0.1];
str = {newname,['<Mean>=',num2str(mna,'%.2f')],['<CutOff>=',num2str(cutoff2,'%.2f')]};
annotation('textbox',dim,'String',str,'FitBoxToText','on', 'BackgroundColor',[0 0 0.7], 'FaceAlpha',0.2,'Units','normalized','HorizontalAlignment','left','FontSize',12);
I have tried the following but no luck.
str = {\bfboldnewname,['<Mean>=',num2str(mna,'%.2f')],['<CutOff>=',num2str(cutoff2,'%.2f')]};

Best Answer

str = {newname, ['<Mean>=',num2str(mna,'%.2f')], ['<CutOff>=',num2str(cutoff2,'%.2f')]};
str{1} = ['\bf ', str{1}, ' \rm']; %\bf to set to bold, \rm to reset back to normal afterward
annotation('textbox',dim,'String',str,'FitBoxToText','on', 'BackgroundColor',[0 0 0.7], 'FaceAlpha',0.2,'Units','normalized','HorizontalAlignment','left','FontSize',12);
Related Question