The blank before var >0.5 cause error in R2016a
3 ビュー (過去 30 日間)
古いコメントを表示
I found a strange behavior in R2016a command line. The additional blank before > cause problem:
>> aAreaVec = rand(5,1)
aAreaVec =
0.8147
0.9058
0.1270
0.9134
0.6324
>> aAreaVec>0.5
ans =
1
1
0
1
1
>> aAreaVec >0.5
Error: "aAreaVec" 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.
0 件のコメント
採用された回答
Walter Roberson
2024 年 7 月 8 日
You are running into Command Function Equivalence https://www.mathworks.com/help/matlab/matlab_prog/command-vs-function-syntax.html
aAreaVec>0.5
is parsed as a relational operator comparing aAreaVec and 0.5
aAreaVec >0.5
is parsed as a call to a function named aAreaVec with parameter '>0.5'
which fails because aAreaVec is known as a variable and so cannot also be a function call.
The correction is to either use
aAreaVec>0.5
or
aAreaVec > 0.5
or to not have the code as the first expression; for example it would work to use
disp(aAreaVec >0.5)
0 件のコメント
その他の回答 (1 件)
Mathieu NOE
2024 年 7 月 8 日
I don't think it has to do with a specific release
I have the same result with R2020a
now either you put no space or at least one space before and after the <
in your case ( 1 space beore , none after) will throw an error
0 件のコメント
参考
カテゴリ
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!