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)

Antworten (1)

Stephen23
Stephen23 am 15 Apr. 2020
Bearbeitet: Stephen23 am 15 Apr. 2020
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).

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2019b

Gefragt:

am 15 Apr. 2020

Bearbeitet:

am 15 Apr. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by