1.code dưới mã pn thì chạy bình thường, còn mấy mã khác bị sai kích thước "Matrix dimensions must agree." .
2. cùng code nhưng dùng điều chế QPSK và QAM thì sửa như thế nào?
Ai rành chỉ dùm em với. cám ơn nhiều ạ
2. cùng code nhưng dùng điều chế QPSK và QAM thì sửa như thế nào?
Ai rành chỉ dùm em với. cám ơn nhiều ạ
function thuchien_Callback(hObject, eventdata, handles)
% hObject handle to thuchien (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
valpn=get(handles.pn,'value');
valm=get(handles.m,'value');
valg=get(handles.gold,'value');
valw=get(handles.walsh,'value');
if valpn == 1
b=round(rand(1,30));
pattern=[];
for k=1:30
if b(1,k)==0
sig=-ones(1,20);
else
sig=ones(1,20);
end
pattern=[pattern sig];
end
d=round(rand(1,120));
pn_seq=[];
carrier=[];
t=[0:2*pi/4:2*pi]; % Creating 5 samples for one cosine
for k=1:120
if d(1,k)==0
sig=-ones(1,5);
else
sig=ones(1,5);
end
c=cos(t);
carrier=[carrier c];
pn_seq=[pn_seq sig];
end
axes(handles.axes1)
plot(pattern);
axis([-1 620 -1.5 1.5]);
title('Du lieu goc');
axes(handles.axes2)
plot(pn_seq);
axis([-1 620 -1.5 1.5]);
title('Ma PN');
axes(handles.axes3)
spreaded_sig=pattern.*pn_seq;
plot(spreaded_sig)
axis([-1 620 -1.5 1.5]);
title('Tin hieu trai pho');
axes(handles.axes4)
bpsk_sig=spreaded_sig.*carrier; % Modulating the signal
plot(bpsk_sig)
axis([-1 620 -1.5 1.5]);
title('Chuoi sau dieu che');
end
if valm == 1
b=round(rand(1,30));
pattern=[];
for k=1:30
if b(1,k)==0
sig=-ones(1,20);
else
sig=ones(1,20);
end
pattern=[pattern sig];
end
d=round(rand(1,120));
carrier=[];
t=[0:2*pi/4:2*pi]; % Creating 5 samples for one cosine
for k=1:120
if d(1,k)==0
sig=-ones(1,5);
else
sig=ones(1,5);
end
c=cos(t);
carrier=[carrier c];
end
axes(handles.axes1)
plot(pattern);
axis([-1 620 -1.5 1.5]);
title('Du lieu goc');
axes(handles.axes2)
plot(m_seq1);
axis([1 20 -1.5 1.5]);
title('Ma M');
axes(handles.axes3)
spreaded_sig=pattern.*m_seq1;
plot(spreaded_sig)
axis([-1 620 -1.5 1.5]);
title('Tin hieu trai pho');
axes(handles.axes4)
bpsk_sig=spreaded_sig.*carrier; % Modulating the signal
plot(bpsk_sig)
axis([-1 620 -1.5 1.5]);
title('Chuoi sau dieu che');
end
if valg == 1
b=round(rand(1,30));
pattern=[];
for k=1:30
if b(1,k)==0
sig=-ones(1,20);
else
sig=ones(1,20);
end
pattern=[pattern sig];
end
d=round(rand(1,120));
carrier=[];
t=[0:2*pi/4:2*pi]; % Creating 5 samples for one cosine
for k=1:120
if d(1,k)==0
sig=-ones(1,5);
else
sig=ones(1,5);
end
c=cos(t);
carrier=[carrier c];
end
axes(handles.axes1)
plot(pattern);
axis([-1 620 -1.5 1.5]);
title('Du lieu goc');
axes(handles.axes2)
plot(gold_seq1);
axis([1 20 -1.5 1.5]);
title('Ma Gold');
axes(handles.axes3)
spreaded_sig=pattern.*gold_seq1;
plot(spreaded_sig)
axis([-1 620 -1.5 1.5]);
title('Tin hieu trai pho');
axes(handles.axes4)
bpsk_sig=spreaded_sig.*carrier; % Modulating the signal
plot(bpsk_sig)
axis([-1 620 -1.5 1.5]);
title('Chuoi sau dieu che');
end
if valw == 1
b=round(rand(1,30));
pattern=[];
for k=1:30
if b(1,k)==0
sig=-ones(1,20);
else
sig=ones(1,20);
end
pattern=[pattern sig];
end
d=round(rand(1,120));
carrier=[];
t=[0:2*pi/4:2*pi]; % Creating 5 samples for one cosine
for k=1:120
if d(1,k)==0
sig=-ones(1,5);
else
sig=ones(1,5);
end
c=cos(t);
carrier=[carrier c];
end
axes(handles.axes1)
plot(pattern);
axis([-1 620 -1.5 1.5]);
title('Du lieu goc');
axes(handles.axes2)
plot(walsh1);
axis([0 20 -0.2 1.2]);
title('Ma Walsh');
axes(handles.axes3)
spreaded_sig=pattern.*walsh1;
plot(spreaded_sig)
axis([-1 620 -1.5 1.5]);
title('Tin hieu trai pho');
axes(handles.axes4)
bpsk_sig=spreaded_sig.*carrier; % Modulating the signal
plot(bpsk_sig)
axis([-1 620 -1.5 1.5]);
title('Chuoi sau dieu che');
end
% hObject handle to thuchien (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
valpn=get(handles.pn,'value');
valm=get(handles.m,'value');
valg=get(handles.gold,'value');
valw=get(handles.walsh,'value');
if valpn == 1
b=round(rand(1,30));
pattern=[];
for k=1:30
if b(1,k)==0
sig=-ones(1,20);
else
sig=ones(1,20);
end
pattern=[pattern sig];
end
d=round(rand(1,120));
pn_seq=[];
carrier=[];
t=[0:2*pi/4:2*pi]; % Creating 5 samples for one cosine
for k=1:120
if d(1,k)==0
sig=-ones(1,5);
else
sig=ones(1,5);
end
c=cos(t);
carrier=[carrier c];
pn_seq=[pn_seq sig];
end
axes(handles.axes1)
plot(pattern);
axis([-1 620 -1.5 1.5]);
title('Du lieu goc');
axes(handles.axes2)
plot(pn_seq);
axis([-1 620 -1.5 1.5]);
title('Ma PN');
axes(handles.axes3)
spreaded_sig=pattern.*pn_seq;
plot(spreaded_sig)
axis([-1 620 -1.5 1.5]);
title('Tin hieu trai pho');
axes(handles.axes4)
bpsk_sig=spreaded_sig.*carrier; % Modulating the signal
plot(bpsk_sig)
axis([-1 620 -1.5 1.5]);
title('Chuoi sau dieu che');
end
if valm == 1
b=round(rand(1,30));
pattern=[];
for k=1:30
if b(1,k)==0
sig=-ones(1,20);
else
sig=ones(1,20);
end
pattern=[pattern sig];
end
d=round(rand(1,120));
carrier=[];
t=[0:2*pi/4:2*pi]; % Creating 5 samples for one cosine
for k=1:120
if d(1,k)==0
sig=-ones(1,5);
else
sig=ones(1,5);
end
c=cos(t);
carrier=[carrier c];
end
axes(handles.axes1)
plot(pattern);
axis([-1 620 -1.5 1.5]);
title('Du lieu goc');
axes(handles.axes2)
plot(m_seq1);
axis([1 20 -1.5 1.5]);
title('Ma M');
axes(handles.axes3)
spreaded_sig=pattern.*m_seq1;
plot(spreaded_sig)
axis([-1 620 -1.5 1.5]);
title('Tin hieu trai pho');
axes(handles.axes4)
bpsk_sig=spreaded_sig.*carrier; % Modulating the signal
plot(bpsk_sig)
axis([-1 620 -1.5 1.5]);
title('Chuoi sau dieu che');
end
if valg == 1
b=round(rand(1,30));
pattern=[];
for k=1:30
if b(1,k)==0
sig=-ones(1,20);
else
sig=ones(1,20);
end
pattern=[pattern sig];
end
d=round(rand(1,120));
carrier=[];
t=[0:2*pi/4:2*pi]; % Creating 5 samples for one cosine
for k=1:120
if d(1,k)==0
sig=-ones(1,5);
else
sig=ones(1,5);
end
c=cos(t);
carrier=[carrier c];
end
axes(handles.axes1)
plot(pattern);
axis([-1 620 -1.5 1.5]);
title('Du lieu goc');
axes(handles.axes2)
plot(gold_seq1);
axis([1 20 -1.5 1.5]);
title('Ma Gold');
axes(handles.axes3)
spreaded_sig=pattern.*gold_seq1;
plot(spreaded_sig)
axis([-1 620 -1.5 1.5]);
title('Tin hieu trai pho');
axes(handles.axes4)
bpsk_sig=spreaded_sig.*carrier; % Modulating the signal
plot(bpsk_sig)
axis([-1 620 -1.5 1.5]);
title('Chuoi sau dieu che');
end
if valw == 1
b=round(rand(1,30));
pattern=[];
for k=1:30
if b(1,k)==0
sig=-ones(1,20);
else
sig=ones(1,20);
end
pattern=[pattern sig];
end
d=round(rand(1,120));
carrier=[];
t=[0:2*pi/4:2*pi]; % Creating 5 samples for one cosine
for k=1:120
if d(1,k)==0
sig=-ones(1,5);
else
sig=ones(1,5);
end
c=cos(t);
carrier=[carrier c];
end
axes(handles.axes1)
plot(pattern);
axis([-1 620 -1.5 1.5]);
title('Du lieu goc');
axes(handles.axes2)
plot(walsh1);
axis([0 20 -0.2 1.2]);
title('Ma Walsh');
axes(handles.axes3)
spreaded_sig=pattern.*walsh1;
plot(spreaded_sig)
axis([-1 620 -1.5 1.5]);
title('Tin hieu trai pho');
axes(handles.axes4)
bpsk_sig=spreaded_sig.*carrier; % Modulating the signal
plot(bpsk_sig)
axis([-1 620 -1.5 1.5]);
title('Chuoi sau dieu che');
end