How can I remove Input Variable Not Used Warning?

조회 수: 18 (최근 30일)
Harold Kidder
Harold Kidder 2014년 7월 4일
답변: Image Analyst 2014년 7월 4일
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