在Fortran中查找满足条件的数组中最小值的[索引] [英] Finding [index of] the minimal value in array which satisfies a condition in Fortran

查看:1608
本文介绍了在Fortran中查找满足条件的数组中最小值的[索引]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查找大于特定数字的数组中的最小值。我发现了 这个讨论 ,其中我不明白。有 MINLOC ,但它看起来不像我想要的那么多,尽管我没有解析给定示例中传递给它的参数。 (也可以使用循环来做到这一点,但它可能很笨拙。)

解决方案

你可能想 MINVAL

如果你的数组是说,

  array =(/ 21,52,831,46,125,68,7 ,8,549,10 / 

你想找到大于65的最小值,

  variable = minval(array,mask =(array> 65))

这显然会给68。


I am looking for a minimal value in an array which is larger than a certain number. I found this discussion which I don't understand. There is MINLOC, but it looks like it does not do as much as I would like on its own, though I didn't parse the arguments passed to it in the given examples. (It is also possible to do this using a loop but it could be clumsy.)

解决方案

You probably want MINVAL.

If your array is say,

array = (/ 21, 52, 831, 46, 125, 68, 7, 8, 549, 10 /)

And you want to find the minimum value greater than say 65,

variable = minval(array, mask=(array > 65))

which would obviously give 68.

这篇关于在Fortran中查找满足条件的数组中最小值的[索引]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆