How to fix "Too many input arguments" error ?

4 Ansichten (letzte 30 Tage)
sabila nur
sabila nur am 22 Jan. 2014
Beantwortet: Image Analyst am 22 Jan. 2014
I still can't get it what's wrong with my code, I've been searching about how to fix "too many input arguments error" but I still can't solve my problem.
here is my code :
function popupmenu2_Callback(source, eventdata)
str = get(source,'String');
switch str;
case '10'
C_Q = 10;
case '20'
C_Q = 20;
case '30'
C_Q = 30;
case '40'
C_Q = 40;
case '50'
C_Q = 50;
case '60'
C_Q = 60;
case '70'
C_Q = 70;
case '80'
C_Q = 80;
case '90'
C_Q = 90;
case '100'
C_Q = 100;
end
display(C_Q);
end
Thank you very much

Antworten (1)

Image Analyst
Image Analyst am 22 Jan. 2014
Somehow you lost the handles input argument, which you need. The function should look like this:
function popupmenu2_Callback(source, eventdata, handles)
try
str = get(handles.popupmenu2,'String');
if ~isempty(str)
C_Q = str2double(str);
else
C_Q = -1; % or some value to indicate an empty field.
end
catch ME
errorMessage = sprintf('Error in function %s() at line %d.\n\nError Message:\n%s', ...
ME.stack(1).name, ME.stack(1).line, ME.message);
fprintf(1, '%s\n', errorMessage);
uiwait(warndlg(errorMessage));
end

Community Treasure Hunt

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

Start Hunting!

Translated by