www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ReadAndWriteAudioFilesExample.m
%% Read and Write Audio Files % This example shows how to write data to an audio file, get information % about the file, and then read data from the audio file. %% Write to Audio File 1 % Copyright 2015 The MathWorks, Inc. load handel.mat %% Write to Audio File 2 audiowrite('handel.wav',y,Fs) clear y Fs %% Get Information About Audio File info = audioinfo('handel.wav') %% Read Audio File [y,Fs] = audioread('handel.wav'); %% Plot Audio 1 t = 0:seconds(1/Fs):seconds(info.Duration); t = t(1:end-1); %% Plot Audio 2 plot(t,y) xlabel('Time') ylabel('Audio Signal')