フィルターのクリア

How to mute the notification of the official function like this?

12 ビュー (過去 30 日間)
dingcheng
dingcheng 2023 年 8 月 1 日
コメント済み: dingcheng 2023 年 8 月 1 日
I was trying to compare the working speed of the function that I 'd programed with the official function quadprog.
I looped them for 10000 times to erase the tiny error while testing. However, the notification like that also repeated for 10000 times, which was kind of annoying. I was wondering whether it is possible to get rid of the notification in the command window like that:

採用された回答

Mrutyunjaya Hiremath
Mrutyunjaya Hiremath 2023 年 8 月 1 日
  • Yes, you can suppress the output of the quadprog function and avoid displaying the notifications in the command window. MATLAB provides the optimoptions function to control the display and output options for optimization solvers like quadprog. You can set the 'Display' option to 'off' to suppress the output.
  • Here's how you can modify your code to achieve that:
function timeComparison()
% Disable warnings
warning('off', 'all');
% Define your loop here (10000 iterations)
for i = 1:10000
% Your code here
% Call your custom function
% For example:
% result_custom = your_custom_function(input_arguments);
% Call quadprog function and suppress the output
options = optimoptions('quadprog', 'Display', 'off');
result_quadprog = quadprog(..., options);
end
% Enable warnings back (optional, but recommended)
warning('on', 'all');
end
  • By setting 'Display' to 'off' in optimoptions, the notifications and output from quadprog will be suppressed for all iterations within the loop. After the loop is complete, you can enable warnings again using warning('on', 'all'); if needed.
  2 件のコメント
Walter Roberson
Walter Roberson 2023 年 8 月 1 日
Note that with quadprog not accepting an initial point, it follows that quadprog twice with the same function and same constraints but different x0 might give exactly the same result each time.
dingcheng
dingcheng 2023 年 8 月 1 日
Many thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by