How can I add a workspace variable that is generated in a loop?
2 次查看(过去 30 天)
显示 更早的评论
Hi there, thank you in advance, I am generating a report where I use plots and variables generated during a loop. Here's what I am doing: I run my m-file, get variables in work space and figures in different windows. Then, I run a report generator function. My plots are in the right order but my variables from the workspace are just shown for the last iteration, even though I see them in the workspace. I want to have this sequence in my report: Plot, variables, plot, variables... for all the iterations. I attached a screenshot of my report generator function so that you can see the structure of it (I could not attach a .rpt file here).
Should I add my whole m-file inside a "Evaluate MATLAB expression" so that RPG captures all of this information in the report?
Any insight will be very appreciated. Thank you!
0 个评论
采纳的回答
Nitin Khola
2015-8-5
A possible approach to solve this issue is to generate report using components in the Report Generator app. For your case, the components of interest are: For Loop (Logical and Flow Control category), Figure Snapshot (Handle Graphics category), Evaluate MATLAB expression (MATLAB category) and perhaps most importantly, the Variable Table (MATLAB category).
The Variable Table component displays a table containing information about all the variables in the MATLAB workspace. You can choose the kind of information to be displayed for variables, e.g. Name, Value, Memory etc. Hence, if the variables in the workspace are being dynamically changed, the table displays the workspace as it looks like at each iteration. For example, the following report was generated after two iterations using the aforementioned components in the Report Generator app. You can see that the variable "A2" was added in the second iteration.
To use the Report Generator in your case, you would have to modify each of the above components as per your script ("m-file"). For example, instead of writing a ‘for’ loop, use the For Loop component and include the commands that you want to execute in each iteration, in the Evaluate MATLAB expression component. You can learn more about it in the following documentation: You can learn more about it in the following documentation: http://www.mathworks.com/help/rptgen/ug/adding-components-to-the-report-template.html
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!