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 个)
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 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!