R2009 matlab powerpoint functions

조회 수: 6 (최근 30일)
Ihaveaquest
Ihaveaquest 2023년 4월 5일
댓글: Walter Roberson 2023년 4월 6일
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
Ihaveaquest
Ihaveaquest 2023년 4월 6일
error says it exceeds the number of array elements
Walter Roberson
Walter Roberson 2023년 4월 6일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Create Complete PowerPoint Presentations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by