Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Please, help to draw plot between

1 回表示 (過去 30 日間)
EDAN
EDAN 2013 年 12 月 2 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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)

回答 (2 件)

Laura Proctor
Laura Proctor 2013 年 12 月 2 日
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 件のコメント
EDAN
EDAN 2013 年 12 月 2 日
編集済み: EDAN 2013 年 12 月 2 日
thanks! yet, this code occur error...I could not solve this dimensions problem. how about you?

Walter Roberson
Walter Roberson 2013 年 12 月 2 日
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;

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by