How can I remove Input Variable Not Used Warning?

18 次查看(过去 30 天)
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;

采纳的回答

Robert Cumming
Robert Cumming 2014-7-4
编辑:Robert Cumming 2014-7-4
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>

更多回答(2 个)

Ben11
Ben11 2014-7-4
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 2014-7-4
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

类别

Help CenterFile Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by