pause-clc-fprintf-pause ... fprintf is ignored

My thinking was that this:
fprintf('Test %d',1)
pause
clc
fprintf('Test %d',2)
pause
should:
  • Print "Test 1"
  • Wait for the user to press a key
  • Clear the Command Window and print "Test 2"
  • Exit when the user presses a key
However, "Test 2" is never printed. Instead a blank screen is displayed. What am I missing?
I'm using MATLAB Online (R2019b)

5 Kommentare

Daniel M
Daniel M am 3 Dez. 2019
I've had this happen to me before where a command immediately after a clc will print to screen, but then get cleared anyways. It's like MATLAB calls the clc function behind the scenes, runs the fprintf command, and then the clc actually executes.
I wonder if the issue will be solved if you add drawnow() after the clc. Let me know!
Fangjun Jiang
Fangjun Jiang am 3 Dez. 2019
works as expected when I try it in R2019b.
Paul Dostert
Paul Dostert am 3 Dez. 2019
Tried the drawnow() but no luck. It definitely works if the pause is replaced with an input(''), but I'm just curious why the original code doesn't work.
Perhaps you're correct and a clc executes after the next buffer flush?
Paul Dostert
Paul Dostert am 4 Dez. 2019
Any chance you can try it in MATLAB Online just to verify it is having an issue on there?
Navya Seelam
Navya Seelam am 6 Dez. 2019
Hi,
I have brought this issue to the notice of our developers. They will investigate the matter further.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Entering Commands finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2019b

Gefragt:

am 3 Dez. 2019

Kommentiert:

am 6 Dez. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by