フィルターのクリア

how to create a table with different datatypes [ex: char, string ,numbers ,image ] in a same column?

1 回表示 (過去 30 日間)

I need to create auto generated report, which includes text, numbers , and images in a coloum of the table. and then save it as pdf,
column1:
Contents=["User Name","System Name","Date and Time","Plot"]; -(all string)
column 2:
Details=[userName,systemName,dnT, Image]
userName,systemName,dnT belongs to char/string
Image- belongs to image (jpg/png)

  6 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 8 月 28 日
What makes you think that one can not save a file to pdf format via exportgraphics?
Sujay Muniraju
Sujay Muniraju 2023 年 8 月 30 日
編集済み: Sujay Muniraju 2023 年 9 月 1 日
i understand we can export via exportgraphics pdf also thanks.

サインインしてコメントする。

採用された回答

Riya
Riya 2023 年 8 月 30 日
Hello Sujay Muniraju
As per my understanding, you want to create a table with different data types in a single column.
In this case, as a workaround, you can use the "table" data structure in MATLAB.
Please refer the below sample code in this regard:
% Create the data for the table
Contents = ["User Name", "System Name", "Date and Time", "Plot"]
userName = 'ABCD'
systemName = 'My System'
dnT = '2021-09-30 10:30:00'
imagePath = 'C:\path\image.jpg'
% Load the image
imageData = imread(imagePath)
% Create the table
T = table(Contents', {userName; systemName; dnT; imageData}, 'VariableNames', {'Column1', 'Column2'})
% Display the table
disp(T)
In the above code, the Contents variable contains the string values for the first column, and the variables userName, systemName, dnT, and imageData hold the corresponding values for the second column.
Further, to save the table as a PDF, you can use the exportgraphics function in MATLAB. Here's an example onhow you can save the table as a PDF:
% Save the table as a CSV file
writetable(T, 'table.csv');
% Convert the CSV file to PDF using external tools or libraries
% For example, you can use MATLAB's built-in support for calling external commands:
system('libreoffice --convert-to pdf table.csv');
Make sure to replace 'path/to/image.jpg' with the actual path to your image file.
Upon using the "exportgraphics" function with the 'ContentType', 'vector' option, MATLAB will generate a high-quality vector-based PDF file that includes the table and the image.
Besides, please note that if you want to display the image directly in the MATLAB Command Window, you can use the "imshow" function. However, if you want to include the image in the table, you will need to save it separately and provide the path or image data as shown in the sample code above.
For more information regarding the functions used above, you can refer following documents

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by