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

  • Home
  • SEARCH
  • 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 8053029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:43:28+00:00 2026-06-05T07:43:28+00:00

I am working with Matlab code that writes coordinates to a text file as

  • 0

I am working with Matlab code that writes coordinates to a text file as follows:

838959.41800,4713239.59000,1.00000,841305.41800,4708452.59000,1.00000,839175.41800,4712582.59000,1.00000

In the past, I’ve had to open each file individually and add the following to the first line of the .txt document:

x,y,z,
838959.41800,4713239.59000,1.00000,841305.41800,4708452.59000,1.00000,839175.41800,4712582.59000,1.00000

Any ideas on how to automate this process by embedding code which will write “x,y,z,” to the first line of the Matlab output?

Thanks much,

-Aaron

  • 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-05T07:43:30+00:00Added an answer on June 5, 2026 at 7:43 am

    Here is an example:

    x = rand(1,3);
    y = rand(1,3);
    z = rand(1,3);
    
    fid = fopen('data.txt','wt');
    fprintf(fid, 'x,y,z,\n');
    fprintf([repmat('%.6f,',[1 8]) '%.6f\n'], x,y,z)
    fclose(fid);
    

    The output file:

    data.txt

    x,y,z,
    0.694829,0.317099,0.950222,0.034446,0.438744,0.381558,0.765517,0.795200,0.186873
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with a matlab code package that was handed down to me. It
I am working with some matlab code that processes data (in a Kalman Filter)
I am working with a matlab project. And I have a text file like
I'm working on my MATLAB code in a number of different locations, and it
I'm working on research model which outputs results to matlab's .mat file format, and
I'm working on a piece of code in MATLAB using the Image Processing Toolbox,
I'm currently working on a my own neuroimaging toolbox that runs under MATLAB /
I'm working with a Matlab API that loads data from a proprietary format into
I am working on some fourier transform code in matlab, and have come across
I have some working code that does amplitude modulation and plots it. However I'm

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.