error in axis! help me
Mostra commenti meno recenti
clc; clear all ;close all;
close all;
data_size=8;
data=randi([0 1],data_size,1);data=data';
bp=0.000001;
disp('Binary information at transmitter :');
disp(data);
% rep of trans binary info as digital
expand=100;
baseband=zeros(1,length(data)*expand);
for n=1:1:length(data)
if data(n)==1
se=ones(expand,1);
else
data(n)==0;
se=zeros(expand,1);
end
baseband((n-1)*expand+1:n*expand)=se;
end
figure
t_bits=bp/expand:bp/expand:expand*length(data)*(bp/expand);
subplot(2,1,1);
plot(t_bits,baseband,'LineWidth',2.5);grid on;
axis([ 0 bp*length(data) -.5 1.5]);
ylabel('amplitude(volt)');
xlabel(' time(sec)');
title('(Aaesha Mahra ) transmitting information as digital signal');
hold on
%binary PSK MODULATION
A=1; %Amplitude carrier
br=1/bp;%bit rate 1 mbps
f=br*2; % carrier freq 2Mz
t_bit=bp/expand:bp/expand:bp;
ss=length(t_bit);
modulated_signal=zeros(1,length(data)*expand);
subplot(2,1,2);
plot(t_bits,A*sin(2*pi*f*t_bits)); grid on;
ylabel('amplitude(volt)');
xlabel('time(sec)');
title('( Aaesha Mahra) carrier signal');
modulated_signal=zeros(1,length(data)*expand);
for(i=1:1:length(data))
if (data(i)==1)
carrier=A*sin(2*pi*f*t_bit);
else
carrier=1*A*sin(2*pi*f*t_bit+pi);
end
modulated_signal((i-1)*expand+1:i*expand)=carrier;
end
%modulated signal
figure
subplot(2,1,1);
plot(t_bits,modulated_signal);
xlabel('time(sec)');
ylabel('amplitude(volt)');
title('(Aaesha,Mahra) Wave form for binary PSK modulation coresponding binary information')
% binary demodulation
demodulated_data=[];
carrier_receiver=sin(2*pi*f*t_bit);
for n=ss:ss:length(modulated_signal)
demodulated_signal=carrier_receiver.*modulated_signal((n-(ss-1)):n);
z=trapz(t_bit,demodulated_signal);
zz=round((2*z/bp));
if(zz>0)
a=1;
else
a=0;
end
demodulated_data=[demodulated_data a];
end
disp('Binary information at reciver');
disp(demodulated_data);
% rep of binary info as digital signal after PSK demodelation
demodulation_bits_expanded=zeros(length(data)*expand,1);
for n=1:length(demodulated_data);
if demodulated_data==1;
se=ones(1,expand);
else demodulated_data(n)==0
se=zeros(1,expand);
end
demodulated_bits_expanded((n-1)*expand+1:n*expand)=se;
end
subplot(2,1,2);
plot(t_bits,demodulated_bits_expanded,'LineWidth',2.5);grid on;
axis([0 bp*length(demodulated_data) 0 -0.5 1.5])
ylabel('amplitude(volt)');
title('recived information as signal after binary PSK demodulation');
%plot constallation figure PSK%
figure
scatter([-1 1],[0, 0]); axis([-1.5 1.5 -1.5 1.5])
xlabel('in-phase amplitude');
ylabel('quadrature amplitude' );
title('(Aaesha Mahra )constallation diagram for binary PSK modulation');
grid
M=2;
phOffest=0;
symMap='binary';
PSKModulator =comm.PSKModulator(M, phOffest,'SymbolMapping' ,symMap);
constellation(PSKModulator)
Can you review the code and correct the error because I am a newbie on Matlab and I was unable to solve the error?
Risposta accettata
Più risposte (1)
Cris LaPierre
il 14 Set 2021
Modificato: Cris LaPierre
il 14 Set 2021
1 voto
As the error states, you have an unexpected number of values in your axis command. For a 2D plot, you should have 4. Since I don't know which numbers you want to keep, I'll just point you to the relevant documenation page.
- [xmin xmax ymin ymax] — Set the x-axis limits to range from xmin to xmax. Set the y-axis limits to range from ymin to ymax.
1 Commento
Mahra Albadi
il 14 Set 2021
Categorie
Scopri di più su PSK in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





