给定向量a = [1,2,3.2,4,5]和元素x = 3在向量a中,如何找到大于x的确切项? [英] Given a vector a=[1,2, 3.2, 4, 5] and an element x=3 In vector a, how to find the exact entry which is bigger than x?

查看:102
本文介绍了给定向量a = [1,2,3.2,4,5]和元素x = 3在向量a中,如何找到大于x的确切项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定向量a = [1,2,3.2,4,5]和元素x = 3 在向量a中,如何找到大于x的确切项?

Given a vector a=[1,2, 3.2, 4, 5] and an element x=3 In vector a, how to find the exact entry which is bigger than x?

推荐答案

我不确定精确"条目的含义.这将为您提供 all 值大于x:

I'm not sure what you mean by "exact" entry. This will give you indices of all the values greater than x:

indices = find(a > x);

假设a已经排序,这将为您提供第一个索引(即,小于x的最小值):

Assuming a is already sorted, this will give you the index of the first one (i.e. the smallest value greater than x):

index = find(a > x,1);

这篇关于给定向量a = [1,2,3.2,4,5]和元素x = 3在向量a中,如何找到大于x的确切项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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