Azzera filtri
Azzera filtri

Processing files using a for loop

591 visualizzazioni (ultimi 30 giorni)
Matt
Matt il 21 Feb 2012
Commentato: Walter Roberson il 10 Set 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.

Risposta accettata

Walter Roberson
Walter Roberson il 21 Feb 2012

Più risposte (1)

Kevin Holst
Kevin Holst il 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 Commenti
Deepu S S
Deepu S S il 10 Set 2021
Modificato: Walter Roberson il 10 Set 2021
surf(A,,'edgecolor','none');
why using this function i'm very new to MATLAB
Walter Roberson
Walter Roberson il 10 Set 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.

Accedi per commentare.

Categorie

Scopri di più su Environment and Settings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by