PLOT time domain & frequency domain of music signal
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MATLAB PLOT Sinusoidal Music... Can someone help me with how to PLOT my signal for the following code in time domain and frequency domain? Apparently the way I am using PLOT is incorrect.
if true
% code
end
clc
clear all
fs = 8000;
C = 523.251;
F = 698.456;
t = 0:1/fs:0.6;
song = [F*t C*t];
y = sin(2*pi*song);
sound(y,fs);
figure
plot(t,y)
0 Commenti
Risposte (1)
the cyclist
il 20 Apr 2017
Modificato: the cyclist
il 20 Apr 2017
Try this instead
plot([t t+0.6+1/fs],y)
The problem with your code is that you used the t vector twice in generating the song, so y was double the length of t. I fixed that by extending the time vector in the plotting function.
You'll see that there is a discontinuity at t=0.6. The better way to have done this is to define one continuous time vector
t = 0:1/fs:1.2;
and then define your song over segments of that time vector. [But I was too lazy to do all that. :-) ]
2 Commenti
the cyclist
il 20 Apr 2017
Conceptually, this is pretty simple. You need a one-to-one correspondence between your t vector and your y vector, in order to plot them.
To make a simple example, you can do
plot([1 2 3 4],[2 3 5 7])
but you are trying to do
plot([1 2 3 4],[2 3 5 7 9 11 13 17])
which will give an error because those vectors do not have a one-to-one correspondence.
So, using your new t1 etc vectors, it looks like your full time sequence is something like
t = [t1 t2+max(t1) t3+max(t1)+max(t2)]
and then you can plot your y value against that time vector.
Vedere anche
Categorie
Scopri di più su Audio and Video Data in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!