matlab 中num2str 问题救助~
发布网友
发布时间:2022-11-21 14:50
我来回答
共1个回答
热心网友
时间:2024-12-12 16:37
clear all
T=4;
width=2;
A=0.5;
t1=-T/2:0.01:T/2;
ft1=0.5*[abs(t1)<width/2];
t=[t1-T t1 t1+T];
ft=repmat(ft1,1,3);
subplot(3,1,1);
plot(t,ft);
w0=2*pi/T;
N=6;K=0:N;
for k=0:N Fn(k+1)=quadv([num2str(A),'*rectpuls(t,2)*exp(-i*',num2str(k),'*',num2str(w0),'*t)'],-T/2,T/2)/T;%现在对了
end
subplot(3,2,3);
stem(K*w0,abs(Fn));
xlabel('nw0');title('magnitude spectrum');
%phase
ph=angle(Fn);
subplot(3,2,4);
stem(K*w0,ph);
xlabel('nw0');
title('phase spectrum');
%sythesis
t=-2*T:0.01:2*T;
K=[0:N]';
ft=Fn*exp(j*w0*K*t);
subplot(3,1,3);
plot(t,ft);
title('sythesized square wavefom');