Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Please, help to draw plot between
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I wonder why this code occur error and how can i fix this code to make AM modulate.
I think sampling is the problem for this case.
---------code------
% wavread
[m,f]=wavread('test.wav');
% time
dt = 1/f; % sampling Time
t = (1:dt:1000); % t axis; I don't know what i set
% Define carrier frequency and amplitude for modulation
fc = 1000;
Ac = 1;
c = Ac * cos(2*pi*fc*t); % Carrier wave, unmodulated
% AM modulation
ka = 0.009;
sAM = (1 + ka*m).* c;
plot(t,sAM)
0 Kommentare
Antworten (2)
Laura Proctor
am 2 Dez. 2013
There seemed to be an issue with the dimensions of variables m and c. The following code shouldn't error.
% wavread
[m,f]=wavread('test.wav');
% time
dt = 1/f; % sampling Time
tf = dt*(length(m)-1);
t = (0:dt:tf)';
% Define carrier frequency and amplitude for modulation
fc = 1000;
Ac = 1;
c = Ac * cos(2*pi*fc*t); % Carrier wave, unmodulated
% AM modulation
ka = 0.009;
sAM = (1 + ka*m).* c;
plot(t,sAM)
Walter Roberson
am 2 Dez. 2013
wavread() returns a matrix which going down is samples and going across is channels.
Your code does not account for multiple channels.
Your code tries to do an element-by-element multiplication between "m", the actual samples, and t, which has been created as if there are 999 seconds worth of samples, plus one extra. For example if f = 4, dt = 1/4, then 1:dt:2 would be [1 5/4 3/2 7/4 2] which would be 1 second (2-1) of data plus one extra sample. The length of t should instead be determined by the number of samples. Try
t = (0:size(m,1)-1) ./ f;
0 Kommentare
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
