我试图找到x数组的偶数和奇数部分,但它返回我错误使用干,x必须与Y长度相同这是我在matlab中的代码
close all;
clear all;
clc;
n1 = -5:1:5;
AM = 19390;
x = [1,9,3,9,0,1,1,9,3,9,0];
fun(x,n1);
function [sima,xr] = fun(t,x)
x_reverse = fliplr(x);% time reversal
sima = 0.5*(x + x_reverse); %even component
xr = 0.5*(x - x_reverse); %odd component
subplot(3,1,1);
stem(t,x);
title('Your signal x')
subplot(3,1,2);
stem(t,sima);
title('Even part');
subplot(3,1,3);
stem(t,xr);
title('Odd part');
end
fun
的输入反向。
写
fun(x,n1)
你应该有
fun(n1,x)
这或反转fun
中每个stem
的每个引用向量和值向量的顺序。