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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:53:31+00:00 2026-06-15T09:53:31+00:00

I want to collect data from the Android accelerometer and write it on a

  • 0

I want to collect data from the Android accelerometer and write it on a file. The file is stored on the SDCard and then I manually copy to the computer by adbpull comand. Then I want to analyze the values on Matlab.

What’s the best way to do? I tried writting the parameters as a string but I dont know how to read then on Matlab.

        WriteOnFile(FdataAcc, String.valueOf(event.timestamp) 
                                + " " + mAcceleration[0] 
                                + " " + mAcceleration[1]
                                + " " + mAcceleration[2] + "\n");  

    public void WriteOnFile(File filename, String data){
    try{
        DataOutputStream dos = new DataOutputStream( new FileOutputStream(filename,true));
        //new appended stream
        dos.writeChars(data);
        dos.close();
        }
        catch(Exception e){;}

}

I also tried to write the values as float, but still I cant read on Matlab.

    public void WriteOnFile(File filename, long data){
    try{
        DataOutputStream dos = new DataOutputStream( new FileOutputStream(filename,true));
        dos.writeFloat((float)data);
        dos.writeChars(" ");
        dos.writeFloat((float) mAcceleration[0]);
        dos.writeChars(" ");
        dos.writeFloat((float) mAcceleration[1]);
        dos.writeChars(" ");
        dos.writeFloat((float) mAcceleration[2]);
        dos.writeChars("\n");
        dos.close();
        }
        catch(Exception e){;}

}

What’s the best way to do? Should I use Dataoutputstream to write in a file? Sensor values are floats.
Thanks in advance.

  • 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-15T09:53:32+00:00Added an answer on June 15, 2026 at 9:53 am

    You should use the second example you showed, but don’t write the characters between the floats.

    When you do fopen on matlab, make sure you put in the machine format argument. You might need to experiment with it until you get the right format, but it will work. Do help fopen to see the options.

    then all you have to do in order to read in all the data is

    fid = fopen(filename,'r',MACHINEFORMAT);
    data = fread(fid,inf,'float32');  %float32 is for single precision float
    

    Or, if you want to read into an array:

    data = fread(fid,[M,inf],'float32');
    

    Where M is the number of elements in each column in the array.

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

Sidebar

Related Questions

i want to collect the data from database in the array and then after
I want my C# program to collect data. Then, when the OK button is
I am new to android and working on accelerometer. I want to collect 20
I want to collect performance data from a Windows 2008 R2 Server with PowerShell.
I want to use ExecuteReader with CommandBehavior to collect data from an SQL table
I want to collect some data from the front page of a website. I
To clarify: I want to collect data from from a hardware sensor and display
I have this script that collects data from users and I want to check
I have the following situation: 2 swingworkers with session which collect data from the
I am developing a desktop application that will need to collect data (from the

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.