Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

clear;
a = arduino();
s1 = servo(a, 'D9', 'MinPulseDuration', 700*10^-6, 'MaxPulseDuration',
2300*10^-6); **** % Initiating Servo 1
s2 = servo(a, 'D10', 'MinPulseDuration', 700*10^-6, 'MaxPulseDuration',
2300*10^-6); ***** % Initiating Servo 2
writePosition(s1, 0); % Reset Servo 1
writePosition(s2, 0); % Reset Servo 2
I am getting the error "Invalid expression. When calling a function or indexing a variable, use parentheses.
Otherwise, check for mismatched delimiters." It is saying the error is where the asterisks are. Apparently the commas after 'MaxPulseDuration' and the closing parentheses are incorrect?
Please help. Unsure of what exactly is wrong. (there is more code following these lines, of course, but there are no error messages, so it has been omitted)

답변 (1개)

Stephen23
Stephen23 2020년 4월 15일
편집: Stephen23 2020년 4월 15일
Use an ellipsis (three dots) to continue code onto the next line:
s1 = servo(a, 'D9', 'MinPulseDuration', 700*10^-6, 'MaxPulseDuration', ...
2300*10^-6); % ^^^ you need this!
Or simply include that last part onto the same line (the world is no longer stuck in the 1960's with everything displayed on 80 flickering green characters).

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2020년 4월 15일

편집:

2020년 4월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by