From 2 given values find the range from a vector
10 ビュー (過去 30 日間)
古いコメントを表示
for example if i have a vector D=[110 140 160 225 280 315 355 400 450 500] and values Dmin=112 and Dmax=356 (always find the value rounded to the bigger number of the vector). i Want to find Range=[140 160 225 280 315 355 400]
Thank you
0 件のコメント
回答 (3 件)
Azzi Abdelmalek
2016 年 8 月 8 日
編集済み: Azzi Abdelmalek
2016 年 8 月 8 日
Edit
D=[110 140 160 225 280 315 355 400 450 500]
Dmin=112
Dmax=356
ii1=find(D>=Dmin,1)
ii2=find(D>=Dmax,1)
out=D(ii1:ii2)
1 件のコメント
Stephen23
2016 年 8 月 8 日
Note that this method will return an empty vector when Dmax is >= max(D). This might be undesired behavior.
Alexandros Samp
2016 年 8 月 8 日
3 件のコメント
Stephen23
2016 年 8 月 8 日
編集済み: Stephen23
2016 年 8 月 9 日
@Alexandros Samp: Have you actually tried my answer yet? My answer does exactly what you are requesting. Here, I can show you for the third time that it gives you the correct output:
D = [110,140,160,225,280,315,355,400,450,500]
Dmin = 340;
Dmax = 700;
idx = Dmin<=D & [true,D(1:end-1)<=Dmax];
out = D(idx)
and the output:
>> out
out =
355 400 450 500
参考
カテゴリ
Help Center および File Exchange で Linear Algebra についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!