How to display a string array in a figure
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ethan Scott
am 27 Nov. 2019
Beantwortet: Walter Roberson
am 27 Nov. 2019
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:

0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 27 Nov. 2019
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!