MATLAB: How to include a table with data in a common figure window

datafigureMATLABtabletext;

I have a plot of data and would like to simply create a table within the same figure window displaying a matrix of data – preferably without using ActiveX controls. I only need this information as a text.

Best Answer

This ability is not available in MATLAB 7.5 (R2007b) and previous releases. The UITABLE feature has been added into MATLAB 7.6(R2008a).
As a workaround you could use the the following kind of code:
figure
plot(sin(1:0.1:20));
set(gca,'position',[0.1300 0.1100 0.7750 0.5750]);
title('Diagram Title');
text(0,1.7,sprintf('Data\ndata1\ndata2\n...\ndata10'));
text(30,1.7,sprintf('Info1\ni1-data1\ni1-data2\n...\ni1-data10'));
text(60,1.7,sprintf('Info2\ni2-data1\ni2-data2\n...\ni2-data10'));
% the position of the text boxes is defined with regard to the axes ticks
% this becomes clearer when executing, e.g.:
% text(0,0,sprintf('Data\ndata1\ndata2\n...\ndata10'));
%
% for reading the data from a variable you could use:
% var = {'Data','data1','data2','data3','data10'}
% text(0,1.7,sprintf([var{1},'\n',var{2},'\n',var{3},'\n',var{4},'\n',var{5}]));
Related Question