arrays - 通过在元素之间包含零来对向量进行上采样

我正在尝试制作一个上采样代码,所以我想在一个向量中插入一个零向量,如下所示:

z=[0 0]%Zeros Vector
x=[1 2 3 4]%Vector to Upsample
y=[1 0 0 2 0 0 3 0 0 4 0 0]%Vector Upsampled

我有这个代码:

fs=20;
N=50;
T=1/fs;
n=0:1:N-1;
L=3;
M=2;
x = exp(-0.5*n*T).*sin(2*pi*n*T);
A=zeros(1,L);
disp(A);
for i = 1:M:length(x)
  x(:,i)=A;

 end
 disp(x);

但是我遇到了这个错误:

A(I,J,...) = X: dimensions mismatch

知道我该怎么做吗?

最佳答案

忘记循环。使用以下解决方案:

out = zeros(1,length(x)*L);
out(:,1:L:end) = x

https://stackoverflow.com/questions/39027430/

相关文章:

google-visualization - 谷歌半 donut 饼图 : is it possib

matrix - 将下三角矩阵转换为向量 [JULIA]

ms-access - MS Access 2013 仅显示启动表单,仅显示其他内容

r - 计算R中每分钟的平均值

pandas - 水平排列两个地 block

r - 如何在 lm() 之后在 R 中复制 Stata 的 "margins at"

laravel - 如何在 Laravel 的 Eloquent 模型中覆盖 ModelNotFou

android-fragments - 如何在android中使searchView的提示居中?

r - 如何在 R 中获得 ping 响应

python - 建立新连接失败