moonnightingale
Full Member level 6
Re: Matlab gives error when i increase bits from 42 to 43 or
I have made a code in Matlab. The is regarding modulation scheme.
It ruuns well till the time I set the number of bits to 42.
When i increase number of bits from 42 to 43 or any other value higher than that it gives error
The error is
?? Error using ==> plot
Vectors must be the same lengths.
Error in ==> BaseBandModulator at 23
plot(t1,y) % shift the Nyquist pulse by one T and then plot
Error in ==> d2 at 21
NyquistPulsesData = BaseBandModulator(data,number_of_bits)
What is so special shift from 43 and higher. If any body is willing to help me, kindly give me ur email. i will send u code and u kindly clarify my query.Thanks
Added after 23 minutes:
i AM postiing the code of that function
When i inrease number of bits from 42 to 43 it gives error
Number of bits are defiined in main function
function NyquistPulsesData = BaseBandModulator(data,number_of_bits)
lowLimit = -0.5; %lower limit for time array "t"
upperLimit = 0.5;
T = 0.1;
t = [lowLimit:0.01:upperLimit]; % this time array does not change
tempData = [];
tempTime = [];
for k = 1:1:number_of_bits
t1 = [lowLimit:0.01:upperLimit] % this time array changes at each for loop iteration; both ends of array shift by T
ln = length(t1)
k
if data(k) == 1; % for Binary one generate a Nyquist pulse
y = sinc(t/T);
if k ==1 % If data is binary one & first member in data array
plot(t,y)
tempData = y;
end
if k > 1
********************************************************
plot(t1,y) % shift the Nyquist pulse by one T and then plot
**********************DUE TO THIS ERROR MESSAGE COMES
tempData = [tempData, zeros(1,10)] + [zeros(1,(k-1)*10),y];
%tempData = [tempData,y];
end
grid
hold on
end
if data(k) == 0 % if data element is zero
for m = 1:101
y(m) = 0;
end
if k ==1
plot(t,y)
tempData = y;
end
if k > 1
************************************************************
plot(t1,y)
***********************DUE TO THIS ERROR MESSAGE COMES
tempData = [tempData, zeros(1,10)] + [zeros(1,(k-1)*10),y];
%tempData is sued to find out the resultant of all the pulsese
end
grid
hold on
end
lowLimit = lowLimit + 0.1
upperLimit = upperLimit + 0.1
%ylim([-1.5 1.5]);
end
title('Nyquist Pulses');
grid
NyquistPulsesData = tempData;
time = -0.5:0.01
0.5 + (number_of_bits -1)*0.1);
%time = tempTime;
% hold off
figure(3)
plot(time,NyquistPulsesData)
title('BASE BAND SIGNAL VS TIME');
grid
ylim([-1.5 1.5]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I have made a code in Matlab. The is regarding modulation scheme.
It ruuns well till the time I set the number of bits to 42.
When i increase number of bits from 42 to 43 or any other value higher than that it gives error
The error is
?? Error using ==> plot
Vectors must be the same lengths.
Error in ==> BaseBandModulator at 23
plot(t1,y) % shift the Nyquist pulse by one T and then plot
Error in ==> d2 at 21
NyquistPulsesData = BaseBandModulator(data,number_of_bits)
What is so special shift from 43 and higher. If any body is willing to help me, kindly give me ur email. i will send u code and u kindly clarify my query.Thanks
Added after 23 minutes:
i AM postiing the code of that function
When i inrease number of bits from 42 to 43 it gives error
Number of bits are defiined in main function
function NyquistPulsesData = BaseBandModulator(data,number_of_bits)
lowLimit = -0.5; %lower limit for time array "t"
upperLimit = 0.5;
T = 0.1;
t = [lowLimit:0.01:upperLimit]; % this time array does not change
tempData = [];
tempTime = [];
for k = 1:1:number_of_bits
t1 = [lowLimit:0.01:upperLimit] % this time array changes at each for loop iteration; both ends of array shift by T
ln = length(t1)
k
if data(k) == 1; % for Binary one generate a Nyquist pulse
y = sinc(t/T);
if k ==1 % If data is binary one & first member in data array
plot(t,y)
tempData = y;
end
if k > 1
********************************************************
plot(t1,y) % shift the Nyquist pulse by one T and then plot
**********************DUE TO THIS ERROR MESSAGE COMES
tempData = [tempData, zeros(1,10)] + [zeros(1,(k-1)*10),y];
%tempData = [tempData,y];
end
grid
hold on
end
if data(k) == 0 % if data element is zero
for m = 1:101
y(m) = 0;
end
if k ==1
plot(t,y)
tempData = y;
end
if k > 1
************************************************************
plot(t1,y)
***********************DUE TO THIS ERROR MESSAGE COMES
tempData = [tempData, zeros(1,10)] + [zeros(1,(k-1)*10),y];
%tempData is sued to find out the resultant of all the pulsese
end
grid
hold on
end
lowLimit = lowLimit + 0.1
upperLimit = upperLimit + 0.1
%ylim([-1.5 1.5]);
end
title('Nyquist Pulses');
grid
NyquistPulsesData = tempData;
time = -0.5:0.01
%time = tempTime;
% hold off
figure(3)
plot(time,NyquistPulsesData)
title('BASE BAND SIGNAL VS TIME');
grid
ylim([-1.5 1.5]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%