1

I have a signal which is defined as x , I want to modulate it than demodulate it to get my very first signal.To see what is going on i need to sketch out my x, my modualted x and my demodulated x.

fs = 5000; %sampling frequency in Hz
fc = 1000; %Carrier function's sampling Frequency
duration = 2; %signal duration in seconds
t = linspace(0,2,duration*fs); %create time axis


x = 2*cos(20*t);
fDev = 50;
modx = fmmod(x,fc,fs, fDev);
demodx = fmdemod(modx, fc, fs);
%Time domain plots
subplot(3,1,1)
plot(t,x) %plot our first graph
title('Time Domain Signal')
xlabel('time (s)')
xlim([0 2])
ylim([-2 2])

subplot(3,1,2)
plot(t,modx) %plot modulated graph
title('Frequency Modulated Signal')
xlabel('time (s)')
xlim([0 2])
ylim([-2 2])

subplot(3,1,3)
plot(t,demodx) %plot demodulated graph
title('Frequency Demodulated Signal')
xlabel('time (s)')

This script is working fine for modulating and sektching out x . But things got messed up when i try to demodulate it. I got an error called

error: plt2vv: vector lengths must match
error: called from plt>plt2vv at line 487 column 5 plt>plt2 at line 246 column 14 plt at line 113 column 17 plot at line 222 column 10 my_script.m at line 27 column 1

This is telling me that error is on plot(t,demodx)

Why i get this error? What am i doing wrong? Why cant i plot?

  • Here is a link of my workspace in order to demonstrate easiy http://octave-online.net/?s=OVTNTagggUEAJyTeLBwwbNpKNzREdpPwbHLPWBFqCVDHERrH – Emre Hayırcı Dec 04 '16 at 12:37
  • If you run your code with the link above you'll see that demox has a size 1x9999 and t has size 1x10000. If you want to plot two vectors, they have to have the same size as the message tells you – Andy Dec 04 '16 at 13:48

0 Answers0