在两行之间使用插值(Using interpolation between two rows)

编程入门 行业动态 更新时间:2024-10-22 15:27:21
两行之间使用插值(Using interpolation between two rows)

我正在尝试插值。 我有一个2*1000的矩阵Y 第一行是时间1秒的Y值,第二行是时间3秒的Y值。 我想在1.7秒时获得Y值

例如,

at time 1 sec Y(1,:)=[1 3 4 6 8 1 4 2 9] and X=[1 2 3 4 5 6 7 8 9] at time 3 sec Y(2,:)=[2 6 8 1 9 2 7 8 2] and X=[1 2 3 4 5 6 7 8 9] at time 4 sec Y(3,:)=[21 6 81 1 9 12 7 28 2] and X=[1 2 3 4 5 6 7 8 9]

我试图插入时间。 我用了

Y_1_7 = interp1(Y(1,:),Y(2,:),1.7);

它不起作用

谢谢

I am trying to do interpolation. I have a matrix Y with 2*1000. The first row is Y values at time 1 sec and the second row is Y values at time 3 second. I am trying to get Y values at time 1.7 sec

For example,

at time 1 sec Y(1,:)=[1 3 4 6 8 1 4 2 9] and X=[1 2 3 4 5 6 7 8 9] at time 3 sec Y(2,:)=[2 6 8 1 9 2 7 8 2] and X=[1 2 3 4 5 6 7 8 9] at time 4 sec Y(3,:)=[21 6 81 1 9 12 7 28 2] and X=[1 2 3 4 5 6 7 8 9]

I am trying to interpolate with respect to time. I used

Y_1_7 = interp1(Y(1,:),Y(2,:),1.7);

It is not working

Thanks

最满意答案

https://www.mathworks.com/help/matlab/ref/interp1.html?requestedDomain=www.mathworks.com似乎对此有帮助

vq = interp1(x,v,xq)使用线性插值返回特定查询点处的1-D函数的插值。

向量x包含样本点 ,v包含相应的值 v(x)。 向量xq包含查询点的坐标。 如果您有多组数据在相同的点坐标处采样,则可以将v作为数组传递。 数组v的每列包含一组不同的1-D样本值。

所以它应该是这样的:

Y_1_7 = interp1([1 3 4], Y, 1.7)

https://www.mathworks.com/help/matlab/ref/interp1.html?requestedDomain=www.mathworks.com seems helpful here

vq = interp1(x,v,xq) returns interpolated values of a 1-D function at specific query points using linear interpolation.

Vector x contains the sample points, and v contains the corresponding values, v(x). Vector xq contains the coordinates of the query points. If you have multiple sets of data that are sampled at the same point coordinates, then you can pass v as an array. Each column of array v contains a different set of 1-D sample values.

So it should be something like:

Y_1_7 = interp1([1 3 4], Y, 1.7)

更多推荐

本文发布于:2023-08-04 23:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1424580.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:两行   插值   rows   interpolation

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!