The procedure for managing print and numbers in the publication function "MATLAB"

I have a simple MATLAB script that prints some text and displays numbers in a loop, e.g.

for i = 1:3 x = randn(100, 1); fprintf('Mean = %.2f\n', mean(x)); fprintf('Std = %.2f\n', std(x)); figure; plot(cumsum(x)); end 

I want to use the publish function to create an HTML file containing the output of this script, with text and numbers alternating as they are in the loop, that is, they order that they appear in the output, there should be

  • Text from the first cycle
  • Figures from the first cycle
  • Text in the second cycle
  • Figures of the second cycle
  • Text from the third cycle
  • Figures from the third cycle

However, the output is currently displayed in the following order

  • Text from the first cycle
  • Text in the second cycle
  • Text from the third cycle
  • Figures from the first cycle
  • Figures of the second cycle
  • Figures from the third cycle

How can I achieve the desired result?

+7
matlab
source share
1 answer

Inside the loop, just before end , enable the snapnow command. This will force the publishing process to take a snapshot instantly, rather than waiting for the loop to collect all the images.

+7
source share

All Articles