我正在尝试制作一个上采样代码,所以我想在一个向量中插入一个零向量,如下所示:
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
关于arrays - 通过在元素之间包含零来对向量进行上采样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39027430/