an error in modulation

1 次查看(过去 30 天)
ahmad ramadan
ahmad ramadan 2019-2-25
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 个)

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

标签

产品


版本

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by