How to display a message as flashing and in my desired color and font size?
7 views (last 30 days)
Show older comments
Commented: DGM on 1 Feb 2023
I want to display the following message in flashing and in my desired color and font size:
" Yes, the error is the same "
I am coding like this but it gives error:
disp('Yes, the error is the same','r','fontsize',5)
Moved: DGM on 1 Feb 2023
If you want it in the command window, then your options are severely limited, and the rate at which you can "flash" will be limited. Also bear in mind that this blocks the user from doing anything while the text is flashing. Going out of your way to make text flash is an expensive exercise in annoying anyone who ever has to use your code.
Text size and font in the console is defined in preferences. Colors can be configured to some degree if you use cprintf(). It will be laggy and the color will be glitchy. Are there other ways to do this? I don't know. Maybe there is with the new UI. Is it a good idea? I doubt it.
mytext = 'this is a bad design decision';
timeon = 1;
timeoff = 0.5;
numcycles = 10;
for k = 1:numcycles
% print the text
% delete the text
cprintf('red','%s\n',mytext); % leave the message in place?
If you can settle for losing color, you can do the same with fprintf(), and at least it will be faster.
More Answers (1)
John D'Errico on 1 Feb 2023
Edited: John D'Errico on 1 Feb 2023
You can do that, but since disp is not written to accept those extra arguments, it might not work. Wanting code to do what you want is always a valid thing to try, but it rarely works.
You CAN use cprintf though, to do at least some of what you want.
Find more on Entering Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!