フィルターのクリア

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

1 回表示 (過去 30 日間)
(50*y).*(28.065*cos(60*t+0.2094395101999999*x)+22.7058*cos(2*(60*t+0.2094395101999999*x))+15.1368*cos(3*(60*t+0.2094395101999999*x))+7.014*cos(4*(60*t+0.2094395101999999*x));
The error given is 'unexpected paranthesis'.

採用された回答

Walter Roberson
Walter Roberson 2012 年 6 月 21 日
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.
  2 件のコメント
Sargondjani
Sargondjani 2012 年 6 月 21 日
tip: if you go with your cursor over a bracket, you will see which bracket it is 'connected' with
Jan
Jan 2012 年 6 月 21 日
@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.

サインインしてコメントする。

その他の回答 (1 件)

Dr. Siva Malla
Dr. Siva Malla 2012 年 6 月 21 日
this is correct:
(50*y)*(28.065*cos(60*t+0.2094395101999999*x))+22.7058*cos(2*(60*t+0.2094395101999999*x))+15.1368*cos(3*(60*t+0.2094395101999999*x))+7.014*cos(4*(60*t+0.2094395101999999*x));
  1 件のコメント
Jan
Jan 2012 年 6 月 21 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by