Not enough input arguments in while loop

조회 수: 15 (최근 30일)
William
William 2012년 6월 24일
I have the code below that basically, when my start button is pretty it changes a variable that relates to the mode that should be running, and then calls the function to check the mode variable and in turn then runs the appropriate function. The function basically reads values from 4 sliders, converts the values into radians and then creates a serial link plot of them. However, i keep getting an error telling my i have insufficient input arguments when it gets to the
o = get(handles.omegaval,'Value');
code lines and i've tried adding various arguments that occured to me but none seemes to help, what do i need please?
function startbtn_Callback(hObject, eventdata, handles)
global moden
moden = 1;
set(handles.statusdisp,'String','Running');
readvals
function readvals (hObject, eventdata, handles)
global o
global a
global b
global g
global rado
global rada
global radb
global radg
global fourlink
global moden
while moden==1 do
o = get(handles.omegaval,'Value');
rado = (o*pi)/180;
a = get(handles.alphaval,'Value');
rada = (a*pi)/180;
b = get(handles.betaval,'Value');
radb = (b*pi)/180;
g = get(handles.gammaval,'Value');
radg = (g*pi)/180;
% Virtual Robot Setup %
% The robot is defined by Denavit-Hartenberg parameters
% theta d a alpha sigma
L(1) = Link([0 0 1 0 0]);
L(2) = Link([0 0 1 0 0]);
L(3) = Link([0 0 0.1 pi/2 0]);
L(4) = Link([0 0 1 0 0]);
fourlink = SerialLink(L, 'name', 'four link');
fourlink.plot([rado rada radb radg]);
end

답변 (1개)

Walter Roberson
Walter Roberson 2012년 6월 24일
I believe you have mis-understood the error. I believe the actual error is that you call readvals without passing any arguments. In startbtn_Callback you should be using
readvals([] [], handles)
When you call a function that takes arguments, the function call procedure will not take the arguments from the calling routine if you do not supply specific arguments.
  댓글 수: 2
William
William 2012년 6월 25일
That makes sense, I had forgotten that was necessary though I've tried amending it and it still doesn't seem to work. What arguments should I need that I might not be thinking of?
I also have a function that is called and functions as such:
.......
elseif moden == 2
manualdrive(handles,eventdata,hObject)
set(handles.omegaleft.'Visible','on');
and this returns not enough input arguments also. Now the arguments are there for both where the function is call and at the function statement but still not working and all I want is to alter the visibility
William
William 2012년 6월 25일
sorry that code was:
.......
elseif moden == 2
manualdrive(handles,eventdata,hObject)
function manualdrive(handles,eventdata,hObject)
set(handles.omegaleft.'Visible','on');

댓글을 달려면 로그인하십시오.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by