4.2 Whiteboard Coordinate System Error for Function

I am currently going through the Arudino Matlab Engeering Kit, starting with the drawing Robot, and ran into a coding error message that I can not figure out. My code:
function xy = countsToXY(counts,Z_i,Base) % Define constants
countsPerRadian = countsPerRevolution/(2\*pi);
r_spool = 0.0045; % Convert counts to angle
phi = counts/countsPerRadian; % Convert angle to change in string length
dStringLength = r_spool*phi; % Convert change in string length to change in Z
dZ = dStringLength/2; %Add change in Z to initial Z to get current Z
z = Z_i + dz; % Compute x and y from Z1 and Z2
x = (Base^2 + z(1)^2 - z(2)^2)/(2*Base);
y = sqrt(z(1)^2-x^2); xy = [x y];
end
But the error that I keep getting is:
Error: File: countsToXY.m Line: 2 Column: 46
Invalid use of operator.
Is there something that I'm missing or was not explained within the lesson that I need to run this code?

Respuestas (1)

Torsten
Torsten el 3 de Mayo de 2024
Movida: Steven Lord el 3 de Mayo de 2024
This arithmetic operation is not defined in MATLAB:
2\*pi

2 comentarios

Connor
Connor el 7 de Mayo de 2024
How can I make it into an arithmetic operation that is defined
Depends on what you want to do:
2\pi
ans = 1.5708
2*pi
ans = 6.2832

Iniciar sesión para comentar.

Productos

Versión

R2019a

Preguntada:

el 3 de Mayo de 2024

Comentada:

el 7 de Mayo de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by