Processing files using a for loop

600 次查看(过去 30 天)
I am trying to write a program to read in files and analyze each file one by one. The files are wav files, and I want to read them in, filter them with a filter I have already designed, plot frequency vs. time and do a spectrogram of each file. I am supposed to use uigetdir to find the directory of files I want to read into MATLAB, and then analyze each one, hopefully with a 'for loop'. I'm not too advanced, so this may be easy and I'm just missing how to do it. Any help would be appreciated.

采纳的回答

Walter Roberson
Walter Roberson 2012-2-21

更多回答(1 个)

Kevin Holst
Kevin Holst 2012-2-21
something like this:
myDir = uigetdir; %gets directory
myFiles = dir(fullfile(myDir,'*.wav'); %gets all wav files in struct
for k = 1:length(myFiles)
baseFileName = myFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
[wavData, Fs] = wavread(fullFileName);
% all of your actions for filtering and plotting go here
end
  9 个评论
Deepu S S
Deepu S S 2021-9-10
编辑:Walter Roberson 2021-9-10
surf(A,,'edgecolor','none');
why using this function i'm very new to MATLAB
Walter Roberson
Walter Roberson 2021-9-10
Compare:
A = sort(randi([-2 9], 300, 500));
surf(A)
title('edgecolor default')
figure
surf(A, 'edgecolor', 'none')
title('edgecolor none')
Notice that the first of the two surface plots is nearly completely black, but the second of them, with edgecolor none, looks fine.
The difference is that in the first one, all the edges have been drawn in black. But edges have fixed drawing width: if you draw an edge and then zoom the plot in or out, the edge stays the same thickness on the screen. When you have enough data that the view has to zoom out to look at it all, then the data coordinates get squished together compared to physical drawing coordinates, so the data coordinates at which the edges get drawn get closer together, but the width of the edges stays the same. At some point, the edges are pretty much touching, and all you can see is the edges.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by