Invalid syntax error with a simple code

조회 수: 5 (최근 30일)
Ahmad Jundi
Ahmad Jundi . 2020년 11월 5일
댓글: Ahmad Jundi . 2020년 11월 5일
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일
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
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개)


Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기




Community Treasure Hunt

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

Start Hunting!

Translated by