R2009 matlab powerpoint functions

7 views (last 30 days)
Ihaveaquest
Ihaveaquest on 5 Apr 2023
Commented: Walter Roberson on 6 Apr 2023
I am having getting erros due top what i think having an older version of matlab.. the section that opens and adds figures to the powerpoint to woirk in older matlab 2009 version
%Powerpoint function
import mlreportgen.ppt.*
% Check if PowerPoint is running
[status, result] = system('tasklist /FI "IMAGENAME eq Powerpnt.exe"');
is_running = contains(result, 'Powerpnt.exe');
if is_running
if exist('Plotted Circulator', 'file')==0
system('taskkill /F /IM POWERPNT.EXE');
end
else
end
fsize = 6;
%trial plots
x = 0:pi/10:2*pi;
y = sin(x);
y2 = sin(x-0.25);
y3 = sin(x-0.5);
%this loop sets the characterictics fo the plot and saves plot to png file
%in numerical order
while k <= fsize
%initializes figure
figure('Name','Measured Data','NumberTitle','off');
%initializes figure size and position on screen
xwidthfig = 450;
ywidthfig = 350;
xwidthscr = 650;
ywidthscr = 650;
%figure characteristics
h = figure(k);
set(gcf,'PaperPositionMode','auto')
set(h, 'Position',[xwidthscr ywidthscr xwidthfig ywidthfig])
%plots sample figures
plot(x,y,'b',x,y2,'r--o',x,y3,'g*');
%saves figures to png format
saveas(gcf,sprintf('fig%d.png', k));
%increases counter for loops
k = k +1;
%powerpoint loop
if k > fsize
k =1;
%%%%%% this section
ppt = Presentation('Plotted figures');
open(ppt)
while k <= fsize
img = Picture(sprintf('fig%d.png',k));
s(k) = add(ppt,'Title and Picture');
replace(s(k),'Title',' Figure');
replace(s(k),'Picture',img);
k = k +1;
end
close(ppt);
close all;
continue
end
end
%deletes png created to avoid memory overload
delete *.png
%View the presentation
rptview(ppt);
  6 Comments
Ihaveaquest
Ihaveaquest on 6 Apr 2023
error says it exceeds the number of array elements
Walter Roberson
Walter Roberson on 6 Apr 2023
slide_count = get(Presentation.Slides, 'Count');
That is a scalar.
slide_count = int32(double(slide_count)+1);
You increment the slide count scalar by 1.
slide = invoke(Presentation.Slides, 'Add', slide_count(i), 11); %crashes here after the first run
but there you try to index that scalar slide_count at index i.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!