如何绘制多项式
How to plot a polynomials
我正在尝试绘制图像中显示的这些多项式,但我一直收到错误,而且我不知道我的代码是否正确。
能否请你帮忙?
问候
多项式:
代码:
clear all
close all
clc
%%
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1024; % Length of signal
t = 2*(0:L-1)*T; % Time vector
x = 0;
c = 1+i;
P(1) = 1;
Q(1) = 1;
P(2) = P(1) + exp(i*(2^(0))*t)*Q(1);
Q(2) = P(1) - exp(i*(2^(0))*t)*Q(1);
P(3) = P(2) + exp(i*(2^(1))*t)*Q(2);
Q(3) = P(2) - exp(i*(2^(1))*t)*Q(2);
P(4) = P(3) + exp(i*(2^(2))*t)*Q(3);
Q(4) = P(3) - exp(i*(2^(2))*t)*Q(3);
for m=1:16
x = x +c*exp(i*2*pi*m*t).*P(m);
end
figure
subplot(2,2,1)
plot(t,P(3))
title('signal')
这是对您编写的代码的快速修复。
clear all
close all
clc
%%
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1024; % Length of signal
t = 2*(0:L-1)*T; % Time vector
x = zeros(1,L);
c = 1+1i;
P = zeros(16,L); Q= zeros(16,L);
P(1,:) = 1;
Q(1,:) = 1;
for j = 1:16
P(j+1,:) = P(j,:) + exp(1i*(2^j)*t).*Q(j,:);
Q(j+1,:) = P(j,:) - exp(1i*(2^j)*t).*Q(j,:);
end
for m=1:16
x = x +c*exp(i*2*pi*m*t).*P(m,:);
end
figure
subplot(2,2,1)
plot(t,P(3,:))
title('signal')
我正在尝试绘制图像中显示的这些多项式,但我一直收到错误,而且我不知道我的代码是否正确。 能否请你帮忙? 问候
多项式:
代码:
clear all
close all
clc
%%
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1024; % Length of signal
t = 2*(0:L-1)*T; % Time vector
x = 0;
c = 1+i;
P(1) = 1;
Q(1) = 1;
P(2) = P(1) + exp(i*(2^(0))*t)*Q(1);
Q(2) = P(1) - exp(i*(2^(0))*t)*Q(1);
P(3) = P(2) + exp(i*(2^(1))*t)*Q(2);
Q(3) = P(2) - exp(i*(2^(1))*t)*Q(2);
P(4) = P(3) + exp(i*(2^(2))*t)*Q(3);
Q(4) = P(3) - exp(i*(2^(2))*t)*Q(3);
for m=1:16
x = x +c*exp(i*2*pi*m*t).*P(m);
end
figure
subplot(2,2,1)
plot(t,P(3))
title('signal')
这是对您编写的代码的快速修复。
clear all
close all
clc
%%
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1024; % Length of signal
t = 2*(0:L-1)*T; % Time vector
x = zeros(1,L);
c = 1+1i;
P = zeros(16,L); Q= zeros(16,L);
P(1,:) = 1;
Q(1,:) = 1;
for j = 1:16
P(j+1,:) = P(j,:) + exp(1i*(2^j)*t).*Q(j,:);
Q(j+1,:) = P(j,:) - exp(1i*(2^j)*t).*Q(j,:);
end
for m=1:16
x = x +c*exp(i*2*pi*m*t).*P(m,:);
end
figure
subplot(2,2,1)
plot(t,P(3,:))
title('signal')