MATLAB Answers

Create the table in the MS word

28 views (last 30 days)
Adam Mariusz Kuryla
Adam Mariusz Kuryla on 21 Nov 2019
Answered: Kavya Vuriti on 26 Nov 2019
I have a guestion, since still I do not know how to process with tables, that are going to be exported into word file. I would like to create any table and then for example put figure into one cell and a text into the other one. Can someone give me the example code, that could help me to get familiar with processing tables ?
Thank you

Answers (1)

Kavya Vuriti
Kavya Vuriti on 26 Nov 2019
Assuming you are trying to create a table of images and text in different columns, images can be stored as arrays in the table. If you have a folder containing images named ‘myfolder’ and a MATLAB variable named ‘imagecontent’ stored as cell array of strings with the text corresponding to images , the following sample code can be used to create table:
% List contents of the folder
info = dir myfolder;
% Get number of images in the folder
numimages = numel(info);
% Create table
T = table(cell(1, numimages), imagecontent);
for k = 1:numimages
filename = info(k).name;
% Fill the table with image information
filecontent = {imread(filename)};
T(k,1) = filecontent;
Also note that length of vector ‘imagecontent’ must be same as number of images to create table. While exporting a table from MATLAB, only specific file formats are supported. Refer this link for supported file formats.
Refer to the following link for more information on working with tables:

Community Treasure Hunt

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

Start Hunting!