How to display a string array in a figure

18 次查看(过去 30 天)
I would like to display the contents of a string array in a figure (for example, showing a table of parameters used in a model fit).
To accomplish this, I have tried to display the contents as a string array in an annotation over top the figure. For example, I plot some function into a figure, then add an annotation which is a string array of the values I want to display. The main issue I am experiencing is that the array displays top down intead of as an actual array (i.e. it displays the values in a vertical line rather than say a 3x5 matrix).
My question is: how can I get the contents of the string array to display as a matrix in the annotation rather than a vertical display of the contents of the array?
Here is a minimal working example of the issue:
x = linspace(0,1);
plot(x,cos(x));
header = ["symbol_1" "symbol_2" "symbol_3" "symbol_4" "symbol_5"];
values = [1 2 3 4 5; 6 7 8 9 10];
array = [header;values];
annotation('textbox',[.15 .15 0.5 0.5],'string',array);
Here is what the code produces:
Here is what I'd like to produce:

采纳的回答

Walter Roberson
Walter Roberson 2019-11-27
Set the annotation Interpreter to latex, and use latex matrix constructions, such as https://www.mathworks.com/matlabcentral/answers/280414-latex-in-live-scripts-using-matrix
For example ''$\pmatrix{1 & 2 \cr 3 & 4}$''

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by