如何使用插值法在MATLAB中将向量的大小加倍? [英] How do I double the size of a vector in MATLAB with interpolation?

查看:145
本文介绍了如何使用插值法在MATLAB中将向量的大小加倍?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,如果我有以下矩阵:

Essentially, if I have the following matrix:

[1, 2, 3 ,4, 10]

我需要在插值时将其爆炸,如下所示:

I need to explode it whilst interpolating, as follows:

[1, 1.5, 2, 2.5, 3, 3.5, 4, 7, 10].

本质上,通过填充两个周围值的平均值来增强它的效果.

Essentially, buff it up by filling in the average of the two surrounding values.

如果我需要对n执行此操作,而不是像我们在这里那样仅添加1个值.

Say if I need to do this for n instead of adding just 1 value as we have here.

推荐答案

您需要将interp1'linear'插值方法一起使用:

You need to use interp1 with 'linear' interpolation method:

>> v = [1 2 3 4 10];
>> newNum = 13; % new number of elements in the "buffed" vector
>> iv = interp1( linspace(0,1,numel(v)), v, linspace(0,1,newNum) )
iv =
1.0000    1.3333    1.6667    2.0000    2.3333    2.6667    3.0000    3.3333    3.6667    4.0000    6.0000    8.0000   10.0000

这篇关于如何使用插值法在MATLAB中将向量的大小加倍?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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