如何让matlab输出指定位置的数据是多少?。

比如t=0:0.01:5
经过运算得到很多离散数据。我想在想知道t=3.1时候,对应的数据,应该怎么找出来?

 Respuesta aceptada

vevim
vevim el 25 de Nov. de 2022

0 votos

因为 t=0:0.01:5 是经过浮点运算得出的离散数值,这些数值实际上是有浮点误差的,所以,你无法使用 find(t==3.1) 来查找索引。不过你可以用下面的办法索引:
t(round(3.1/0.01)+1)
假设你计算出的对应 t 的数据是 y,那么 y 中对应 t = 3.1 的数据就是:
y(round(3.1/0.01)+1)

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 25 de Nov. de 2022

Respondida:

el 25 de Nov. de 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!