I am trying to write a simple MatLab code but continue to get an error that I can't find a fix for.
x = [-2 -1.5 -1 -0.5 0 0.5 1 1.5 2];
y = (x+x(sqrt(x+3)))*(1+2(x^(2)));
The error is at line 2, on the parenthesis that is bolded between the 2 and x. Any reason why?
Error: File: Assignment2.m Line: 2 Column: 26
Invalid expression. When calling a function or
indexing a variable, use parentheses. Otherwise,
check for mismatched delimiters.

 採用された回答

Rafael Hernandez-Walls
Rafael Hernandez-Walls 2020 年 11 月 5 日

0 投票

tray this
x = [-2 -1.5 -1 -0.5 0 0.5 1 1.5 2];
y = (x+x.*(sqrt(x+3))).*(1+2*(x.^(2)));

2 件のコメント

Walter Roberson
Walter Roberson 2020 年 11 月 5 日
Right. MATLAB has absolutely NO implied multiplication, anywhere. Not even inside the symbolic toolbox internal language.
Ahmad Jundi
Ahmad Jundi 2020 年 11 月 5 日
Ahh I see now I didn't know that! Thank you so much this helped a lot!
p.s. I am extremely knew to MatLab and want to learn how to use it.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Get Started with MATLAB についてさらに検索

製品

リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by