Error:not enough input arguments
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I need to calibrate an magentometer but when i press run it says that i don't have enough input arguments on line 24.Any advice?function calCo = calibrate(out)
%Initially no offset and unity gain
calCo.offset = 0;
calCo.g = 1;
mx_max = -1e9;
my_max = -1e9;
mz_max = -1e9;
mx_min = 1e9;
my_min = 1e9;
mz_min = 1e9;
%Display wait bar dialog box to show calibration is running
statusBox = waitbar(0, 'Rotate magnetometer in the x-y plane', ...
'Name','Calibration');
%Start a stopwatch timer
tic;
t_stop=10;
%Read raw magnetometer ouput for t_stop seconds as it is rotated
while toc <= t_stop
[mx, my, mz] = readMag(out, calCo);
%Store max/min values=Nort/South;
mx_max = max(mx_max,mx);
my_max = max(my_max,my);
mx_min = min(mx_min,mx);
my_min = min(my_min,my);
%Update wait bar
waitbar(toc/t_stop, statusBox)
end
%Reset timer and waitbar ,with a delay of 1 second to read instructions
waitbar(0, statusBox, 'Rotate magnetpmeter in the x-z plane')
pause(1);
%Read raw magnetometer ouput for t_stop seconds as it is rotated
while toc<= t_stop
[mx, my, mz] = readMag(out,calCo);
%Store max/min values=Nort/South;
mz_max = max (mz_max,mz);
mz_min = min (mz_min, mz);
%Update wait bar
waitbar(toc/t_stop, statusBox)
end
%Close wait bar
close(statusBox)
%Calculate offsets for each axis
offsetX = mx_max;
offsetY = my_max;
offsetZ = mz_max;
%Calculate scaling factors
gainX = (mx_sin - offsetX)/180;
gainY = (my_min - offsetY)/180;
gainZ = (mz_min - offsetZ)/180;
calCo.offset = [offsetX offsetY offsetZ];
calCo.g = [gainX,gainY,gainZ];
mbox = msgbox('Sensor calibration complete');
uiwait(mbox);
end
0 Kommentare
Antworten (1)
Steven Lord
am 4 Jan. 2023
You must call your calibrate function with an input argument (whatever your readMag function requires as its first input). You can do this by typing calibrate followed by that input argument in parentheses like calibrate(42) [if 42 was a valid first input to readMag] or (if you want to use the Run button to run your code) by following the steps on this documentation page.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!