parfor in MATLAB Report Generator
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I am wondering if there is any problem using parfor loop and MATLAB Report Generator.
For example, I use the following code to generate one PDF file.
rpt = mlreportgen.report.Report('tmp.pdf');
tp = mlreportgen.report.TitlePage;
tp.Title = 'Magic Squares';
tp.Author = 'Albrecht Durer';
append(rpt,tp);
append(rpt, mlreportgen.report.TableOfContents);
....
close(rpt)
Can I put the above code inside a parfor loop (and I will use different filename for each iteration) to generate one PDF file in each iteration?
0 Kommentare
Antworten (1)
Sandeep Mishra
am 5 Dez. 2024
Hi Kevin,
You can use MATLAB Report Generator with a ‘parfor’ loop to create multiple reports simultaneously, improving efficiency.
Refer to the following example code snippet:
import mlreportgen.dom.*;
import mlreportgen.report.*;
% Define the number of iterations
numIterations = 10;
% Use a parfor loop to execute the report generation 100 times
parfor i = 1:numIterations
rptName = sprintf('report/tmp_%d', i);
rpt = Report(rptName);
tp = TitlePage;
tp.Title = 'Magic Squares';
tp.Author = 'Albrecht Durer';
append(rpt,tp);
append(rpt, TableOfContents);
end
Refer to the following MathWorks Documentation to learn more about ‘parfor’ function: https://www.mathworks.com/help/releases/R2024b/parallel-computing/parfor.html
I hope this helps!
0 Kommentare
Siehe auch
Kategorien
Mehr zu MATLAB Report Generator finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!