How can I remove Input Variable Not Used Warning?

42 visualizzazioni (ultimi 30 giorni)
I used the following function to save curve fit results. I get a warning that fitresult and gof input variables are not used. If I replace these with ~ the function will not work. How can I silence the warning? I am using MATLAB R2014a. Thanks.
function SaveCurveFit(option, fitresult, gof)
switch option
case 1 % North Region
save ('NorthDailyFit','fitresult','gof');
case 2 % Central Region
save ('CentralDailyFit','fitresult','gof');
case 3 % South Region
save ('SouthDailyFit','fitresult','gof');
end;
end;

Risposta accettata

Robert Cumming
Robert Cumming il 4 Lug 2014
Modificato: Robert Cumming il 4 Lug 2014
right click on the function statement line (1) and select the
"Suppress "input argument.... " On this line.
i.e. you will get this:
function SaveCurveFit(option, fitresult, gof) %#ok<INUSD>

Più risposte (2)

Ben11
Ben11 il 4 Lug 2014
If you want to disable all warnings you might want to use this line:
warning('off','all');
But Robert's answer does seem more specific to your function.

Image Analyst
Image Analyst il 4 Lug 2014
See this function I wrote to turn off common errors. Read the instructions in the comments to add any warnings you want.
function TurnOffWarnings
try
% To set the warning state, you must first know the message identifier for the one warning you want to enable.
% Query the last warning to acquire the identifier. For example:
% warnStruct = warning('query', 'last')
% messageID = warnStruct.identifier
% messageID =
% MATLAB:concatenation:integerInteraction
% Turn off this warning "Warning: Image is too big to fit on screen; displaying at 33% "
warning('off', 'Images:initSize:adjustingMag');
% Get rid of warning about roipolyold being deprecated:
% "Warning: Function ROIPOLYOLD will be removed in the future. Use ROIPOLY instead"
warning('off', 'images:removing:function');
% Get rid of warning about directory already existing:
% "Warning: Directory already exists."
warning('off', 'MATLAB:MKDIR:DirectoryExists');
% Turn off note "Warning: Added specified worksheet." that appears in the command window.
warning('off', 'MATLAB:xlswrite:AddSheet');
catch ME
errorMessage = sprintf('Error in function %s() at line %d.\nDo you have the file already open in Excel?\nPlease check that the file is not open anywhere.\n\nError Message:\n%s', ...
ME.stack(1).name, ME.stack(1).line, ME.message);
fprintf(1, '%s\n', errorMessage);
WarnUser(errorMessage);
end
return; % from TurnOffWarnings

Community Treasure Hunt

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

Start Hunting!

Translated by