Trying to get symbols to display a formula in title of uiaxes bar plot
1 view (last 30 days)
Show older comments
Govind Sankar Madhavan Pillai Ramachandran Nair
on 26 Jun 2025
Answered: Govind Sankar Madhavan Pillai Ramachandran Nair
on 26 Jun 2025
I am trying to get symbols to display a formula in title of uiaxes bar plot. In the beginning it was like this. I enter this code :
app.UIAxes_4.Title.String = 'Sigma of each cell, $$\sigma = \sqrt{1/N*\Sigma_N(E-R_{ref})^2}$$'
and then I got this.

This is correct. But I want to add this along with it

This is from another normal plot and i generated this by using the code :
titl1 ='best \sigma = ';
titl2 = num2str(app.bestSigma);
titl3 = ' worst \sigma= ';
titl4 = num2str(app.worstSigma);
titl = strcat(titl1,titl2,titl3,titl4);
app.UIAxes_3.Title.String = titl;
And now I try to combine this :
titl1 ='Sigma of each cell, $$\sigma = \sqrt{1/N*\Sigma_N(E-R_{ref})^2}$$, best \sigma = ';
titl2 = num2str(app.bestSigma);
titl3 = ' worst \sigma= ';
titl4 = num2str(app.worstSigma);
titl = strcat(titl1,titl2,titl3,titl4);
app.UIAxes_4.Title.String = titl;
But I end up getting this :

I even tried this :
app.UIAxes_4.Title.String = "Sigma of each cell, $$\sigma = \sqrt{1/N*\Sigma_N(E-R_{ref})^2}$$, best \sigma = " + num2str(app.bestSigma) + " worst \sigma= " + num2str(app.worstSigma);
and still ended up getting the same wrong answer.
So how can I combine the first two images to get the solutioin for a title in an UIaxes bar plot. Thank you.
1 Comment
Epsilon
on 26 Jun 2025
Edited: Epsilon
on 26 Jun 2025
Try:
titl = sprintf(['Sigma of each cell, $$\\sigma = \\sqrt{\\frac{1}{N}\\sum_N(E-R_{ref})^2}$$, ', ...
'best $\\sigma = %.3f$, worst $\\sigma = %.3f$'], ...
app.bestSigma, app.worstSigma);
app.UIAxes_4.Title.String = titl;
app.UIAxes_4.Title.Interpreter = 'latex';
Answers (1)
See Also
Categories
Find more on Title in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!