MATLAB Answers

Yagnaseni Roy

What is wrong with this expression, why is MATLAB not being able to understand it?

Asked by Yagnaseni Roy
on 21 Jun 2012


The error given is 'unexpected paranthesis'.




No products are associated with this question.

2 Answers

Answer by Walter Roberson
on 21 Jun 2012
 Accepted answer

You have one more '(' than you have ')'

Count brackets. Each time you encounter a '(' add 1, each time you encounter a ')' subtract 1. If you do not end up with 0 then you have a mismatch.

You will find that the '(' in front of '28.065' is not matched.


tip: if you go with your cursor over a bracket, you will see which bracket it is 'connected' with

Jan Simon
on 21 Jun 2012

@Yagnaseni Roy: The error message "unexpected parenthesis" clearly hits the point. Walter's re-phrasing is more detailed.
@Walter: It is not trivial to decide, which of the parentheses is the unmatched one. It could be "(28.065*cos(60*t)+ 0.2094395101999999*x)" also. I'm convinced that you have used a smart pattern matching method trained by years of experiences with structured formulas. Nice, +1.

Answer by Siva Malla
on 21 Jun 2012

this is correct:


  1 Comment

Jan Simon
on 21 Jun 2012

I agree that it is likely, that there is no COS inside the argument of a COS, but I would not dare to call this correct without asking the OP before.

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!