detect output supression in matlab

If you are not seeing any output on the command window or in the output file, it might be due to the output being suppressed. Here are some ways to detect output suppression in Matlab:

  1. Check for supression at the command level using diary:

    Matlab provides a diary command that logs the command window output to a file. You can check if this is enabled using the diary('off') command which turns it off. If this command was called before with the argument 'on' and you don't see any output, then the output is being written to the file specified by the diary command.

    main.m
    diary('on')
    % Your code
    diary('off')
    
    37 chars
    4 lines
  2. Check for supression within the code:

    Matlab has several ways to format output so that it may be suppressed. You can check the following in your code:

    main.m
    % Check if 'fprintf' is being used with the argument '%*s' or '%*f'
    fprintf('%*s', 0, '')
    
    % Check if 'disp' is being used with the keyword 'off'
    disp('output', 'off')
    
    % Check if 'warning' or 'error' commands have been suppressed using 'try-catch'
    try 
        % Your code that throws warning or error
    catch
        % Do nothing or provide an alternative response
    end
    
    361 chars
    13 lines
  3. Check for supression at the program level:

    Check if the program or any dependent functions are suppressing output. The most common commands used to suppress output at the program level are eval and evalc. If any of these commands is used to evaluate the output, then there will be no output generated on the command window.

    main.m
    % Check if 'eval' or 'evalc' command has been used to evaluate the output
    eval('output')
    evalc('output')
    
    105 chars
    4 lines

If you find any of the above problems, you can remove them to see the output on the command window.

gistlibby LogSnag