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?

Antworten (1)

Torsten
Torsten am 3 Mai 2024
Verschoben: Steven Lord am 3 Mai 2024
This arithmetic operation is not defined in MATLAB:
2\*pi

2 Kommentare

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

Melden Sie sich an, um zu kommentieren.

Produkte

Version

R2019a

Gefragt:

am 3 Mai 2024

Kommentiert:

am 7 Mai 2024

Community Treasure Hunt

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

Start Hunting!

Translated by