MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   MATLAB中图形绘图所需的帮助 (https://www.labfans.com/bbs/showthread.php?t=24038)

poster 2019-12-10 20:48

MATLAB中图形绘图所需的帮助
 
我将要介绍我在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文件中没有[IMG]https://i.stack.imgur.com/cSlHl.jpg[/IMG] 。这个空白是我遇到的主要问题。理想情况下,我希望以秒为单位显示x轴!任何帮助将非常感激。

[B]编辑1:[/B]

使用第一个建议的方法:

[IMG]https://i.stack.imgur.com/jKSqS.jpg[/IMG]



[B]回答:[/B]

还有

axis tight 设置轴的“紧”限。参见文档: [URL="http://www.mathworks.com/help/techdoc/ref/axis.html"]http[/URL] : [URL="http://www.mathworks.com/help/techdoc/ref/axis.html"]//www.mathworks.com/help/techdoc/ref/axis.html[/URL]



[url=https://stackoverflow.com/questions/3996023]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 23:17

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.