フィルターのクリア

Create a Table able to be exported in PNG following Latex Type style.

99 ビュー (過去 30 日間)
Jorge Ignacio Cisneros Saldana
Jorge Ignacio Cisneros Saldana 2022 年 7 月 25 日
回答済み: Siraj 2023 年 9 月 13 日
Hello:
I am trying to create a table, that can be exported in the directory in .PNG or any figure type.
The best would be to export it as Latex looking .png.
I tried multiple ways and I cannot succed.
The only conversion I found to create a Latex table is the following. Here you can create a .Tex file.
I would appreciate your help

回答 (1 件)

Siraj
Siraj 2023 年 9 月 13 日
Hi! It is my understanding that you want to export a table as a PNG file.
To export a table as a PNG file, you can utilize MATLAB's "uitable" function. This function creates a table UI component within the current figure and returns the “table” UI component object. The key aspect is to align the table properly so that it occupies the entire figure and appears visually appealing. This can be achieved by adjusting the position of the uitable and figure.
Once the table is positioned correctly, you can convert the figure to an image using the "getframe" and "frame2im" functions. After obtaining the image data, you can save it as a PNG file using the "imwrite" function. To gain a better understanding, refer to the example code provided below.
% creating a table.
LastName = {'Sanchez';'Johnson';'Li';'Diaz';'Brown'};
Age = [38;43;38;40;49];
Smoker = logical([1;0;1;0;1]);
Height = [71;69;64;67;64];
Weight = [176;163;131;133;119];
T = table(LastName,Age,Smoker,Height,Weight);
%create a new figure.
fig = uifigure;
%create a uitable
uit = uitable(fig, "Data",T);
% adjusting the table to fit the entire figure for cleanliness.
uit.Position(3) = fig.Position(3) - 80;
uit.Position(4) = fig.Position(4) - 80;
% Capture the table window as an image
frame = getframe(fig); % Get the current figure window
imageData = frame2im(frame); % Convert the frame to an image
% Save the image as a PNG file
imwrite(imageData, 'table.png');
I have attached "table.png" for your reference
For a more comprehensive understanding of the "uitable" function in MATLAB and its properties, I recommend referring to the following link:
This resource will provide you with detailed information on how to effectively position a table and utilize its various properties.
To learn more about “getframe”, “frame2im” and “imwrite” refer to the following links.
Hope this helps.

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by