Checking inequality condition for each component of a vector.
7 ビュー (過去 30 日間)
古いコメントを表示
I think there is a bug and below is what I saw:
command: vec = [0;-5;6;1.99;-2.01;-2.001;0.5];
-0.1 < vec < 0.1
ans =
0
1
0
0
1
1
0
command: -1.9 < vec < 2.1
ans =
1
1
1
1
1
1
1
I need to apply piecewise univariate function for each component in my code. Can anyone suggest a way to get the correct result?
0 件のコメント
採用された回答
Joe Yeh
2016 年 10 月 3 日
Unlike Python, you can't use multiple inequality expression in MATLAB. You'll have to do this :
-0.1 < vec & vec < 0.1
-1.9 < vec & vec < 2.1
0 件のコメント
その他の回答 (1 件)
Fangjun Jiang
2016 年 10 月 3 日
To explain the result you saw, your command is equal to :
temp=-0.1 < vec;
temp < 0.1
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Scope Variables and Generate Names についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!