我正在尝试插值。 我有一个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)更多推荐
发布评论