作业帮 > 综合 > 作业

matlab 程序中%标注的地方一直报错

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/08 15:46:50
matlab 程序中%标注的地方一直报错
%2FSK仿真程序
clear all;
fs=2000;
dt=1/fs;
f1=20;
f2=120;
a=round(rand(1,10));
g1=a;
g2= a;
g11=(ones(1,2000))*g1;
g1a=g11(:)’;
g21=(ones(1,2000))’*g2;
g2a=g21(:);
t=0:dt:10-dt;
t1=length(t);
fsk1 =g1a.*cos(2*pi*f1.*t);%%%%%%%%%%%%%%%%%%%%%%%%%
fsk2 =g2a.*cos(2*pi*f2.*t);%%%%%%%%%%%%%%%%%%%%%%%%%
fsk=fsk1+fsk2; %产生的信号
no=0.0*randn;
sn=fsk+no;
subplot(311);plot(t,no);
subplot(312);plot(t,fsk);
title(‘信号’);ylabel(‘’信号幅度);
subplot(313);plot(t,sn);
title(‘叠加噪声后的信号’);ylabel(‘幅度A’);xlabel(‘时间t’);
figure(2);
b1=fir1(101,[10/80020/800]);
b2=fir1(101,[90/800110/800]);
H1=fiter(b1,1,sn);H2=fiter(b2,1,sn);
Subplot(211);plot(t,H1);
title(‘经过带通滤波器后f1的波形’);ylabel(‘幅度’);
subplot(212);plot(t,H2);
title(‘经过带通滤波器后f2的波形’);ylabel(‘幅度’);xlabel(‘t’);
sw1=H1.*H1;sw2=H2.*H2;
figure(3);
subplot(211);plot(t,sw1);
title(‘经过相乘器h1后的波形’);ylabel(‘幅度’);
subplot(212);plot(t,sw12);
title(‘经过相乘器h2后的波形’);ylabel(‘?幅度’);xlabel(‘t’);
bn=fir1(101,[2/80010/800]);
figure(4);
st1=filter(bn,1,sw1);st2=filter(bn,1,sw2);
subplot(211);plot(t,st1);
title(‘经过低通滤波器sw1后的波形’);ylabel(‘幅度’);
subplot(212);plot(t,st2);
title(‘经过低通滤波器sw2后的波形’);ylabel(‘幅度’);xlabel(‘t’);
%判决
for(i=1:length(t))
if(st1(i)>=st2(i))st(i)=0;
elsest(i)=st2(i);
end
end
figure(5)
subplot(211);plot(t,st);title(‘经过抽样判决器后的波形’);ylabel(‘幅度’);
subplot(212);plot(t,sn);title(‘原始的波形’);ylabel(‘幅度’);xlabel(‘t’);
%加入噪声后
no=0.3*dandn(1,t1);
sn=fsk+no;帮我改一下这个程序,因为不是很懂,所以没有办法调试,改过之后我再对照原来的错误程序看错在哪里.
%2FSK仿真程序
clear all;
fs=2000;
dt=1/fs;
f1=20;
f2=120;
a=round(rand(1,10));
g1=a;
g2= a;
g11=(ones(1,2000))'*g1;
g1a=g11(:)';
g21=(ones(1,2000))'*g2;
g2a=g21(:)';
t=0:dt:10-dt;
t1=length(t);
fsk1 =g1a.*cos(2*pi*f1.*t);%%%%%%%%%%%%%%%%%%%%%%%%%
fsk2 =g2a.*cos(2*pi*f2.*t);%%%%%%%%%%%%%%%%%%%%%%%%%
fsk=fsk1+fsk2; %产生的信号
no=0.0*randn;
sn=fsk+no;
subplot(311);plot(t,no);
subplot(312);plot(t,fsk);
% title(‘信号’);ylabel(‘’信号幅度);
subplot(313);plot(t,sn);
% title(‘叠加噪声后的信号’);ylabel(‘幅度A’);xlabel(‘时间t’);
figure(2);
b1=fir1(101,[10/80020/800]);
b2=fir1(101,[90/800110/800]);
H1=filter(b1,1,sn);H2=filter(b2,1,sn);
subplot(211);plot(t,H1);
% title(‘经过带通滤波器后f1的波形’);ylabel(‘幅度’);
subplot(212);plot(t,H2);
% title(‘经过带通滤波器后f2的波形’);ylabel(‘幅度’);xlabel(‘t’);
sw1=H1.*H1;
sw2=H2.*H2;
figure(3);
subplot(211);plot(t,sw1);
% title(‘经过相乘器h1后的波形’);ylabel(‘幅度’);
subplot(212);plot(t,sw2);
% title(‘经过相乘器h2后的波形’);ylabel(‘?幅度’);xlabel(‘t’);
bn=fir1(101,[2/80010/800]);
figure(4);
st1=filter(bn,1,sw1);st2=filter(bn,1,sw2);
subplot(211);plot(t,st1);
% title(‘经过低通滤波器sw1后的波形’);ylabel(‘幅度’);
subplot(212);plot(t,st2);
% title(‘经过低通滤波器sw2后的波形’);ylabel(‘幅度’);xlabel(‘t’);
%判决
for(i=1:length(t))
if(st1(i)>=st2(i))st(i)=0;
else st(i)=st2(i);
end
end
figure(5)
subplot(211);plot(t,st);
% title(‘经过抽样判决器后的波形’);ylabel(‘幅度’);
subplot(212);plot(t,sn);
% title(‘原始的波形’);ylabel(‘幅度’);xlabel(‘t’);
%加入噪声后
no=0.3*randn(1,t1);
sn=fsk+no;
.你的错误真是多啊.