Continue displaying output using disp() function
Show older comments
I use disp() in a live script function to track which samples in a data set have been processed in a parfor loop. However, when long enough, the disp() out put will be something like this:
Sample 300 has been processed.
Sample 301 has been...
and will no longer output.
I've looked around and can't seem to how to remove an output limitation. Is there a way to increase/unlimit this or is it immutable?
7 Comments
Sindar
on 31 May 2020
hmm, I can't seem to replicate this in 2020a.
for ind=1:1e3
disp("Sample " + ind + " has been processed.")
end
prints all 1000 lines (you have to scroll a bit). So does
disp("Sample " + (1:1e3)' + " has been processed.")
Can you create a minimal example?
Douglas Miller
on 1 Jun 2020
Sindar
on 1 Jun 2020
So it does! Mine gets to
Sample 1971 has been processed
Sample...
While I think about it, what version do you have and is this the same point that yours stops?
Sindar
on 1 Jun 2020
Notes:
for ind=1:10000
fprintf('Sample %d has been processed\n',ind)
end
ends at exactly the same point.
for ind=1:10000
fprintf('Sample %d\n',ind)
end
ends at
Sample 5092
Sam...
meaning the limit is related to characters, not lines
Sindar
on 1 Jun 2020
So, this might not solve your problem (due to the parfor), but my method for tracking progress is this:
N = 20;
fprintf('%s\n',repmat('o',1,N))
for ind=1:N
% do stuff
fprintf('.')
end
which displays a fairly nice progress bar in the normal command window:
oooooooooooooooooooo
...............
though livescripts split the output, so it's a little harder to compare.
When I have too many iterations to show on one line, I cut it up and get something like:
Running 100 calculations
/5 oooooooooooooooooooo
1 ....................
2 ....................
3 ....................
4 ....................
5 ..............
This may be a solution if we can't figure out a way around the cut-off, and you don't need to know which samples have completed, just how many
Douglas Miller
on 1 Jun 2020
I don't think this is the same problem since we are far below that limit (~6e4 characters) and that has to do with printing to files vs livescript output. Also, note that running the test in the command line prints everything for me.
It seems most likely that your issue is butting against the livescript's intent to avoid doing things like accidentally outputting huge arrays. But, it seems like there should be a way around it
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


