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)

Answers (1)

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).

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Release

R2019b

Asked:

on 15 Apr 2020

Edited:

on 15 Apr 2020

Community Treasure Hunt

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

Start Hunting!