Processing files using a for loop

1.007 Ansichten (letzte 30 Tage)
Matt
Matt am 21 Feb. 2012
Kommentiert: Walter Roberson am 10 Sep. 2021
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.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 21 Feb. 2012

Weitere Antworten (1)

Kevin Holst
Kevin Holst am 21 Feb. 2012
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 Kommentare
Deepu S S
Deepu S S am 10 Sep. 2021
Bearbeitet: Walter Roberson am 10 Sep. 2021
surf(A,,'edgecolor','none');
why using this function i'm very new to MATLAB
Walter Roberson
Walter Roberson am 10 Sep. 2021
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Measurements and Spatial Audio finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by