我将要介绍我在MATLAB中创建的工作,但是在使用plot函数将数据处理为可呈现的形式时遇到了麻烦。
我的代码如下所示:
[inputname, pathname] = uigetfile('*.wav', 'Select WAV-file'); thumb1 = inputname; %# Get filename information fprintf('\n%s is being turned into a 30s thumbnail...\n', thumb1); fprintf('Please wait..!\n\n'); %# load the signal [y, fs, nb] = wavread(thumb1); y = mean(y,2); %# stereo, take avrg of 2 channels %# Calculate frame energy fWidth = round(fs*10e-3); %# 10ms numFrames = floor(length(y)/fWidth); energy = zeros(1,numFrames); for f=1:numFrames energy(f) = sum( y((f-1)*fWidth+1:f*fWidth).^2 ); end 基本上,我想绘制随时间变化的轨迹能量(以秒为单位)。
plot(energy) 几乎可以满足我的要求,但是在曲目的末尾我有非常少的空白空间,.wav文件中没有

。这个空白是我遇到的主要问题。理想情况下,我希望以秒为单位显示x轴!任何帮助将非常感激。
编辑1:
使用第一个建议的方法:
回答:
还有
axis tight 设置轴的“紧”限。参见文档:
http :
//www.mathworks.com/help/techdoc/ref/axis.html
更多&回答...