Invalid syntax at num2str. A'(' might be missing a closing ')'

6 ビュー (過去 30 日間)
Sean Rhoten
Sean Rhoten 2020 年 1 月 26 日
コメント済み: Sean Rhoten 2020 年 1 月 26 日
Hello everyone! Im writing simple code for a intro class and continue to get a syntax error "Invalid expression". For this homework, the instructure wants use num2str that seems to be where my error originates. Im sure its a simple mistake. All help is apriciated. Thank you!
disp((' (a) tanh(e)=' num2str(tanh(exp(1)))))

採用された回答

Image Analyst
Image Analyst 2020 年 1 月 26 日
Why are there 2 (( after disp? Did you count the opening and closing parentheses? As you typed the parentheses, or clicked on one, did you notice the underlines under the matching parenthesis? You should use brackets to concatenate two strings like you're doing. Corrected code:
disp([' (a) tanh(e)=' num2str(tanh(exp(1)))])
I'd use fprintf() instead though.
  1 件のコメント
Sean Rhoten
Sean Rhoten 2020 年 1 月 26 日
Thank you very much! I appricate your help!

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

その他の回答 (1 件)

Cameron B
Cameron B 2020 年 1 月 26 日
disp([' (a) tanh(e)=',num2str(tanh(exp(1)))])

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by