How to display a string array in a figure
19 ビュー (過去 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:

0 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!