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?

답변 (1개)

Torsten
Torsten 2024년 5월 3일
이동: Steven Lord 2024년 5월 3일
This arithmetic operation is not defined in MATLAB:
2\*pi

댓글 수: 2

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

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

카테고리

제품

릴리스

R2019a

질문:

2024년 5월 3일

댓글:

2024년 5월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by