How to avoid loops
1 回表示 (過去 30 日間)
古いコメントを表示
I have an array (3xN, day, longitude, temperature), a vector (10 elements long, TestLongitudes), and a longitude tolerance. I'm attempting to, for each day find the longitudes that are with tolerance of any of the TestLongitudes, and return the mean of the temperatures that meet the criteria. I can write a lot of loops to do the comparisons, but I wonder if there's a better way...
Thanks! Bruce
0 件のコメント
回答 (1 件)
Star Strider
2018 年 2 月 22 日
With respect to comparing the longitudes, the ismembertol function comes quickly to mind. You will have to experiment with it and your data to determine if it’s an appropriate option.
You won’t be avoiding loops, just hiding them. Many of these functions have implicit loops within them.
2 件のコメント
Star Strider
2018 年 2 月 22 日
It can. The functions are optimised, and I believe in many functions, compiled.
My pleasure!
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!