Parse error at x:usage might be invalid matlab syntax
조회 수: 11 (최근 30일)
이전 댓글 표시
Hi,
I am brand new to MATLAB and need some help understanding why I am getting the following error "Parse error at x:usage might be invalid matlab syntax" when trying to run the followin code:
y = 3x + 2;
plot(x,y)
grid on
댓글 수: 0
답변 (1개)
Walter Roberson
2021년 5월 10일
MATLAB has absolutely no implied multiplication. Not anywhere. Not even slipped down behind the sofa cushions.
3x needs a multiplication operator.
댓글 수: 2
Walter Roberson
2021년 5월 11일
If there is no multiplication there, then your reference to 3x would have to be a reference to a function or variable whose name begins with the character '3'. However in MATLAB variables and function names must begin with a Latin letter A through Z or a through z.
I am certain that where you wrote 3x that you intend to multiply 3 and x, and that the multiplication is implied by putting the 3 and the x next to each other. However matlab does not support implied multiplication and you must include a multiplication operator.
참고 항목
카테고리
Help Center 및 File Exchange에서 Argument Definitions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!