Parse error at x:usage might be invalid matlab syntax

5 ビュー (過去 30 日間)
Esa Kesti
Esa Kesti 2021 年 5 月 10 日
コメント済み: Walter Roberson 2021 年 5 月 11 日
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

回答 (1 件)

Walter Roberson
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 件のコメント
Esa Kesti
Esa Kesti 2021 年 5 月 10 日
Thanks for the fast reply, there is no multiplication in use here, this should just plot a line on y=3x+2
Would It be possible to get an example how to plot this?
Thanks already
Walter Roberson
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 ExchangeAnimation についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by