Borrar filtros
Borrar filtros

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

12 visualizaciones (últimos 30 días)
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:

Respuesta aceptada

Mrutyunjaya Hiremath
Mrutyunjaya Hiremath el 1 de Ag. de 2023
  • 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 comentarios
Walter Roberson
Walter Roberson el 1 de Ag. de 2023
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by