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 9253491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:13:57+00:00 2026-06-18T11:13:57+00:00

I have to convert a matlab code into Android. This matlab code contains energy

  • 0

I have to convert a matlab code into Android. This matlab code contains energy calculation as shown below:

first I read the audio file into matrix x, and the sample frequency into fs, and then calculate the energy for each window:

[x, fs] = wavread('C:\1359873105438.wav')
energy=energy+sum(x(1:fs).^2)*Tss;

I am not sure how to convert this into Android/Java.

Have you been through this before? please help me to get over this problem.

thanks in advance for your help

  • 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-18T11:13:59+00:00Added an answer on June 18, 2026 at 11:13 am

    Essentially, you have to do something like this:

    double x;//Read Wave in here
    for (i=0;i<x.length;i++)
    {
        energy+=Tss*(x[i]^2);
    }
    

    How to read the wave files borrowed from this article.

    public class ReadExample
    {
       public static void main(String[] args)
       {
          try
          {
             // Open the wav file specified as the first argument
             WavFile wavFile = WavFile.openWavFile(new File(args[0]));
    
             // Get the number of audio channels in the wav file
             int numChannels = wavFile.getNumChannels();
    
             // Create a buffer of 100 frames
             double[] buffer = new double[100 * numChannels];
    
             int framesRead;
    
             do
             {
                // Read frames into buffer
                framesRead = wavFile.readFrames(buffer, 100);
    
                // Loop through frames and look for minimum and maximum value
                for (int s=0 ; s<framesRead * numChannels ; s++)
                {
                   //This is where you put the your code in
                }
             }
             while (framesRead != 0);
    
             // Close the wavFile
             wavFile.close();
          }
          catch (Exception e)
          {
             System.err.println(e);
          }
       }
    }
    

    Bottom line is, there isn’t a nice clean way to do it like there is in matlab. There isn’t even a function to directly read in a wave file. Still, it’s relatively straight forward, using the WavFile class the website provides.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this C# code and I am trying to convert it to MATLAB
I'm new to Python and I'm needing to convert some Matlab code I have
I have a MATLAB code which I have to convert to C language. According
I'm trying to convert an image into an audio signal in MATLAB by treating
I have an imaging application written in Matlab and need to convert it into
How can I convert this script into a MATLAB function? clear all; set={AB02XY_1,ZT99ER_1,UI87GP_1}; fileData1
I am trying to convert some matlab code from the Maia package into something
I have to convert an incoming String field into a BigDecimal field that would
I have to convert a generic object(s) into a NameValueCollection. I am attempting to
I have an XML file and I have to convert it into a property

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.