Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Please, help to draw plot between

1 visualización (últimos 30 días)
EDAN
EDAN el 2 de Dic. de 2013
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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)

Respuestas (2)

Laura Proctor
Laura Proctor el 2 de Dic. de 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)
  1 comentario
EDAN
EDAN el 2 de Dic. de 2013
Editada: EDAN el 2 de Dic. de 2013
thanks! yet, this code occur error...I could not solve this dimensions problem. how about you?

Walter Roberson
Walter Roberson el 2 de Dic. de 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;

La pregunta está cerrada.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by