Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8277765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:47:03+00:00 2026-06-08T08:47:03+00:00

I am trying to write a program where i have to read a wav

  • 0

I am trying to write a program where i have to read a wav file, extract some features from it and save them and then go and pick the next file repeat the same procedure. the number of wave files to be picked are more than 100. Can someone help me how to read wavfiles one after another. (say the files are named e1.wav,e2.wav and so on). someone please help me

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:47:05+00:00Added an answer on June 8, 2026 at 8:47 am

    The dir command is quite helpful here. It either displays the whole content of a directory but you can also specify a glob to just return a sub-set of files, e.g. dir('*.wav'). This returns an struct-array containing file information such as name, date, bytes, isdir and so on.

    To get started, try the following:

    filelist = dir('*.wav');
    for file = filelist
        fprintf('Processing %s\n', file.name);
        fid = fopen(file.name);
        % Do something here with your file.
        fclose(fid);
    end
    

    Edit 1: Change the double-quotes to single-quotes (thx to user1540393).

    Edit 2 (Suggested by amro): If a processing result has to be stored per file,
    I often use the following pattern. I usually pre-allocate an array, a struct array or
    a cell array of the same size as the filelist. Then I use an integer index to iterate
    over the file list, which I can also use to write the output. If the information to be
    stored is homogeneous (e.g. one scalar per file), use an array or a struct array.
    However, if the information differs from file to file (e.g. vectors or matrices of different size) use a cell array instead.

    An example using an ordinary array:

    filelist = dir('*.wav');
    % Pre-allocate an array to store some per-file information.
    result = zeros(size(filelist));
    for index = 1 : length(filelist)
        fprintf('Processing %s\n', filelist(index).name);
        % Read the sample rate Fs and store it.
        [y, Fs] = wavread(filelist(index).name);
        result(index) = Fs;
    end
    % result(1) .. result(N) contain the sample rates of each file.
    

    An example using a cell array:

    filelist = dir('*.wav');
    % Pre-allocate a cell array to store some per-file information.
    result = cell(size(filelist));
    for index = 1 : length(filelist)
        fprintf('Processing %s\n', filelist(index).name);
        % Read the data of the WAV file and store it.
        y = wavread(filelist(index).name);
        result{index} = y;
    end
    % result{1} .. result{N} contain the data of the WAV files.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have been trying to write a program in python to read two text
I am trying to write a c++ program that would read key frames from
I am trying to write a C++ program to read from a website using
I'm trying to write a simple stock check program, and I have a Table
I have a C program like the one below. I am trying to write
I am trying to write a program that sends basic text files from one
I am trying to write a python program using Python 3 I have to
I am trying to read a file on a network server (from a Windows
I'm trying to write a program that converts from Mayan to Arabic numerals and
I am trying to write a program using python-fuse, but I can't get file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.