Why are my vectors different lengths?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
load 'gong.mat' %Returns sampling frequency Fs and data y
T=1/Fs; %Sampling period
L=1*y; %Number of samples
t=(0:L)*T; %Time vector.
plot(t,y);
I am trying to plot an audio file (gong crash) and am receiving an error in the final line. The error is "Vectors must be the same length." To my understanding, I am compensating for their length by scaling the time vector by dividing by the sampling frequency "Fs."
Thank you for your time and expertise.
1 comentario
Respuestas (2)
Jan
el 2 de Oct. de 2018
Editada: Jan
el 2 de Oct. de 2018
L=1*y; %Number of samples
No. 1*y is the same as y. You did not show how y is defined, by I guess that you want:
L = size(y, 1)
% or
L = size(y, 2)
numel(y) works also, if y is a mono signal, but not for stereo. As Stephen has mentioned already, you have to start at the frame 1, not 0: "1:L" instead of "0:L".
0 comentarios
Ver también
Categorías
Más información sobre Audio I/O and Waveform Generation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!