Error in evaluating report (.RPT) file

2 views (last 30 days)
Hello all,
i have one .RPT file to generate a pdf report. i make use of struct in this RPT file.
i was evaluating this RPT file in my main_script.m and i had struct locally present so it was working fine till now.
report 'SAMReport_PDF_V5_0'; %SAMReport_PDF_V5_0.RPT is my report generation file
but now in the main_script.m i have introduced another function say by name new_function.m and i pass the same struct to this function. but when i evaluate report file from this function it is unable to access struct. why am i seeing this ?
I feel the struct is not visible to .RPT file in new_function.m because %<VariableName> notation is not working now in .RPT file, but i dont understand why because i am able to acess struct locally in that function
new_function(struct);
%code for new function
function new_function(struct)
report 'SAMReport_PDF_V5_0'; %here my report execution throws error. it is unable to read and access fields of struct
end

Accepted Answer

Sajid Afaque
Sajid Afaque on 18 Dec 2024
Hello Community,
I found out the answer for this.
Apparently the report generator tool in matlab is able to acess only global parameters and data from the base workspace.
and is not able to read local workspace data when i am inside new_function.m. Therefore i can send the struct to base workspace and then generate the report.
function new_function(struct)
% Assign the struct to the base workspace
assignin('base', 'struct', struct);
% Generate the report
report 'SAMReport_PDF_V5_0';
% Clear the struct from the base workspace after generating the report
evalin('base', 'clear struct');
end

More Answers (0)

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!