フィルターのクリア

Is this a bug? And if not, why it is defined like that

1 回表示 (過去 30 日間)
Hussein Ammar
Hussein Ammar 2019 年 6 月 5 日
コメント済み: KALYAN ACHARJYA 2019 年 6 月 5 日
Hello all,
I was wondering why this should happen:
clear all
N = 10;
Q = 9;
K = 50;
K *(2 + floor(1/N))
>Output:
Error: File: Untitled6.m Line: 6 Column: 1
"K" was previously used as a variable, conflicting with its use here as the name of a function or command.
See "How MATLAB Recognizes Command Syntax" in the MATLAB documentation for details.
I don't have a defined function named K, and as far as I know there is no defined function named K in matlab, right? it is a constant here. So, why Matlab does not access the current workspace and path to determine whether K is a function or variable.
While for example the next example works fine, why the space after K in the previous form is causing a problem?
clear all
N = 10;
Q = 9;
K = 50;
K*(2 + floor(1/N))
K * (2 + floor(1/N))
K* (2 + floor(1/N))
  2 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 6 月 5 日
No issue, when I tried
kk.png
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 6 月 5 日
Oh I got the point Thanks @Stephen

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

回答 (1 件)

Stephen23
Stephen23 2019 年 6 月 5 日
編集済み: Stephen23 2019 年 6 月 5 日
"Is this a bug?"
Not according to the MATLAB documentation:
"Space after an identifier, but not after a potential operator, implies a function call using command syntax. For example:"
ls ./d
"Therefore, the potentially ambiguous statement ls ./d is a call to the ls function using command syntax."

カテゴリ

Help Center および File ExchangeEntering Commands についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by