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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:06:04+00:00 2026-06-10T05:06:04+00:00

Say you have a simple text file which contains many columns. Some columns are

  • 0

Say you have a simple text file which contains many columns. Some columns are decimal values already. Some are hexadecimal. Those columns are known.

test.txt >>

1.4 1.9 21 0030 0D12
0.3 3.3 91 FFFF 1111

I want to read the first three columns as decimal, and read the last two columns as hex.

Can this be done easily?

Thanks!

  • 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-10T05:06:06+00:00Added an answer on June 10, 2026 at 5:06 am

    It can easily be done by textread. For your example, just do:

    [col1, col2, col3, col4, col5] = textread('myfile.txt', '%f %f %f %s %s');
    

    This will read the decimal values normally, and treat the hexadecimal values as strings.

    If you further wish to convert the strings into decimal values as well, use hex2dec with cellfun:

    [col4, col5] = cellfun(@hex2dec, col4, col5);
    

    Hope this helps.

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

Sidebar

Related Questions

I have a simple script which inserts values from a text file into a
I have a file which contains several text entries, say one two three Now,
I have many source/text file, say file.cpp or file.txt . Now, I want to
(PHP 5.3.6) I have a php file which contains simply this text - there
Say I have a simple table that contains username, firstname, lastname. How do I
Say you have a simple class with some storage data structure (list, vector, queue,
Say I have a simple object which supports implicit casting to System.String public sealed
I have a text file that serves as a simple database, each entry spanning
Say I have an XML file which looks like this: <?xml version=1.0 encoding=UTF-8?> <Project
I have a text file which I read using readlines(). I need to start

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.