How can I remove Input Variable Not Used Warning?

20 ビュー (過去 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 Center および File ExchangeFit Postprocessing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by