How to make Matlab play a specific sound any time (and every time) an error occurs and a different sound when the code finishes normally?
13 ビュー (過去 30 日間)
古いコメントを表示
I'm looking for a way have sound display every time a specific action occurs, for example a beep when an error occurs and a honk when a code finishes. I know that I could put in try, catch and sound if it all works, but I'm looking for a way to do this so it happens every time always. Another way to conceptualize the problem is that anytime red text appears in the command window, make a beep, and anytime >> appears without red text, make a honk.
I was thinking about using groot and the startup file. But I don't know what specific parameters to call or edit.
I'm hoping this is possible with my rational being that, every time an error occurs anywhere, some code is being called to say "Hey, send some red text to the command window." If I could even just piggy back off that and say "Hey, send some red text to the command window, and also play a beep noise", that would be fantastic.
I'm running MATLAB 2018a on Windows 10 64x
0 件のコメント
回答 (1 件)
Karan Singh
2025 年 2 月 24 日
I don't think isn’t a built‐in “global” hook that automatically triggers custom sounds for every error or for when the prompt reappears. In MATLAB the standard error notification (red text and a system beep) is hard‐wired into its internal routines, and while you can disable the built‐in beep with commands like
beep off
or change system settings, there’s no supported callback or event you can attach to detect when red error text is printed or when the normal “>>” prompt appears.
If a global solution is important for your workflow, you might consider submitting a feature request to MathWorks. https://in.mathworks.com/support/contact_us.html
Karan
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!