Error using axis>LocSetLimits (line 325) Vector must have 4, 6, or 8 elements. Error in axis (line 113) LocSetLimi​ts(ax(j),c​ur_arg,nam​es);

21 views (last 30 days)
please help!

Accepted Answer

KSSV
KSSV on 14 Sep 2021
Read about axis. As yours is a 2D plot you need to input four values, which correspond to minx, maxx and miny, maxy.
axis([0 bp*length(demodulated_data)-0.5 0 1.5])
  2 Comments
Mahra Albadi
Mahra Albadi on 14 Sep 2021
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');
Mahra Albadi
Mahra Albadi on 14 Sep 2021
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?

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!