Converting Python to MATLAB Problems.

2 visualizaciones (últimos 30 días)
octopus_love
octopus_love el 31 de Jul. de 2018
Editada: surya venu el 19 de Jul. de 2024
Hello, I have a problem with converting python script to MATLAB.
I used Python and python-pptx which helps to modify the powerpoint contents.
My purpose is to change the table setting in page6.
Here is my code in Python.
prs = py.pptx.Presentation(fileName);
slide = prs.slides[5]; % page6 -> index '5'
table = slide.shapes[4].table; % slide.shapes[4] will be modified. This is a table.
for i in range(4): % That table has 4 rows, and 17 columns.
for j in range(17):
table.cell(i, j).margin_left = 0
table.cell(i, j).margin_right = 0
table.cell(i, j).margin_top = 0
table.cell(i, j).margin_bottom = 0
prs.save('test.pptx')
I know that MATLAB not accept the '[]'(square bracket). So, I tried
prs.slides{py.list({5})};
instead of this line.
slide = prs.slides[5];
But, It doesn't work.
This code well works on Python.
How can I do? Please help.
Thanks in advance. please T_T

Respuestas (1)

surya venu
surya venu el 19 de Jul. de 2024
Editada: surya venu el 19 de Jul. de 2024
Hi,
It is true that indexing in MATLAB and Python are different. Python indexing can't be used in MATLAB.
As an alternative, you have to use objects and functions of that library.
Here is an example MATLAB code:
prs = py.pptx.Presentation(fileName);
slide = prs.slides.get(5);
table = slide.shapes.parent;
For more information on "slides" object, check out:

Categorías

Más información sobre Call Python from MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by