How do i do x1<=x<=x2 in matlab?
1 回表示 (過去 30 日間)
古いコメントを表示
I am trying to enter x1<=x<=x2 for matlab. however i am useless at coding and i cannot find a way to get this to work.
Please help
0 件のコメント
採用された回答
Les Beckham
2023 年 4 月 11 日
編集済み: Les Beckham
2023 年 4 月 11 日
You have to split up the compound condition into two conditions:
(x1 <= x) && (x <= x2)
If these terms are scalars, that will generate a scalar logical value. If they are not scalars, you should read about logical indexing.
Also, if you are just getting started with Matlab, I would highly recommend that you take a couple of hours to go through the free online tutorial: Matlab Onramp
2 件のコメント
その他の回答 (1 件)
Antoni Garcia-Herreros
2023 年 4 月 11 日
Hello Alexander
x=1:10;
%Let's say you want to find the values of x between 3 and 7
x1=3;
x2=7;
x>=3 & x<=7
x(x>=3 & x<=7)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!