an error in modulation
1 view (last 30 days)
Show older comments
i want to translate(modulate) the recorded signal by 5kHz , but i get an error shown below last line
%we define the time interval
fs=100*1000;
ts=1/fs;
t=0:ts:5-ts;
No=length(t) %how many points in t
nbit = 16 ; %Bits per sample
m = audiorecorder(fs,nbit,2)
disp('Start speaking.')
recordblocking(m, 5); %limit the recording by 5 sec
disp('End of Recording.')
play(m); % Play the speech
r = getaudiodata(m);%Store recorded audio signal in numeric array
figure(1) ;
plot (t,r)
xlabel ('time')
ylabel('amplitude') ;
title('speech over time')
%finding the FT for the signals
M=abs(fftshift(fft(r)/No));
%creating the vector for the frequency axis
f=[-No/2:No/2-1]/(No*ts);
figure(2);
plot (f,M) ; % plot the magnitude spectrum
xlabel ('frequency')
ylabel('amplitude') ;
title('Magnitude Spectrum of speech')
fc = 5000; %carrier frequency
c=cos(2*pi*fc*t); % carrier to translate frequency by 5kHz
y = r;
g=r.*c;
%finding the FT for the signals
G=abs(fftshift(fft(g)/No));
figure 2;
plot (f,G) ; % plot the magnitude spectrum of translated signal
xlabel ('frequency')
ylabel('amplitude') ;
title('translated spectrum by 5Khz')
the error is
Error using .*
Matrix dimensions must agree.
Error in ex4 (line 30)
g=r.*c;
0 Comments
Answers (0)
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!