필터 지우기
필터 지우기

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

조회 수: 12 (최근 30일)
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by