While running the following code I am getting a error message "Undefined function 'updateAngle' for input arguments of type double "
Afficher commentaires plus anciens
Actually I was trying to do tehsame thing as given in the video "https://www.youtube.com/watch?v=MF-mqlG6quE" but in the getAngles function I am getting an error in the line marked with '#'it states that "Undefined function 'updateAngle' for input arguments of type double " function [angleX,angleY,angleZ] = getAngles(gyroConnection, gainx,gainy,gainz)
persistent previousRateX; persistent previousRateY; persistent previousRateZ; if(isempty(previousRateX)); previousRateX = 0; end if(isempty(previousRateY)); previousRateY = 0; end if(isempty(previousRateZ)); previousRateZ = 0; end
persistent previousAngleX; persistent previousAngleY; persistent previousAngleZ; if(isempty(previousAngleX)); previousAngleX = 0; end if(isempty(previousAngleY)); previousAngleY = 0; end if(isempty(previousAngleZ)); previousAngleZ = 0; end
persistent previousTime; if(isempty(previousTime)); previousTime = 0; tic; end
[rateX,rateY,rateZ] = readGyro(gyroConnection ,false); currentTime = toc;
newAngleX = calculateAngle(previousRateX, rateX, gainx);
###angleX = updateAngle(previousAngleX + newAngleX);
newAngleY = calculateAngle(previousRateY, rateY, gainy);
angleY = updateAngle(previousAngleY + newAngleY);
newAngleZ = calculateAngle(previousRateZ, rateZ, gainz);
angleZ = updateAngle(previousAngleZ + newAngleZ);
previousRateX = rateX; previousRateY = rateY; previousRateZ = rateZ; previousAngleX = angleX; previousAngleY = angleY; previousAngleZ = angleZ; previousTime = currentTime;
function[angle] = calculateAngle(previousRate, rate,gain)
angle = ((previousRate/2 + rate/2) * (currentTime - previousTime) * gain)/(100);
end function [angle] = update(angle) if(angle < 0) angle = angle + 360; else if(angle > 0) angle = angle - 360; end end end end
pls give me ur suggestions to overcome it. ASAP
Réponses (0)
Catégories
En savoir plus sur Data Type Identification dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!