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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:49:21+00:00 2026-06-18T01:49:21+00:00

I have a file with a data value and timestamp that I am trying

  • 0

I have a file with a data value and timestamp that I am trying to split in Matlab.
This is the format:

-18.151346    Mon Jan 28 11:33:08 2013

I am using the textscan function to try and split it.

data=textscan(fid,'%f%s%s%f%s%n','delimiter','space');

I am trying to split the timestamp into separate columns so that I can just use the time and not the date or year. I had a look at some previous questions which were very similar but for some reason I just can’t get it to do what I want. My resulting cell array is in this format.

Column 1     Column 2   Column 3 
-18.151346   Mon       Jan 28 11:33:08 2013

I am completely new to Matlab so any help would be greatly appreciated.
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-18T01:49:22+00:00Added an answer on June 18, 2026 at 1:49 am
    1. You’re using a 'space' string as a delimiter, which is illegal in textscan. Specify it as ' ' instead.
    2. You want treat consecutive spaces as one, so you should also set the 'MultipleDelimsAsOne' flag to 1.

    The correct syntax should be:

    textscan( fid, '%f%s%s%s%s%n', 'delimiter', ' ', 'MultipleDelimsAsOne', 1);
    

    Had you not tried to tinker with the delimiter option, this behavior would’ve been done properly by default, so just omit all options:

    textscan( fid, '%f%s%s%s%s%n');
    

    Also note that you need a flag for each item in the string that is surrounded by spaces. In other words, for a string like this:

    -18.151346 Mon Jan 28 11:33:08 2013

    the timestamp in string form will be stored in the 5th column of the resulting cell array.

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

Sidebar

Related Questions

I have a data file that looks like this: xyz123 2.000 -0.3974 0.0 hij123
I have file with data fields in this format YYYY-MM-DD HH:MM:SS but I noticed
So I have this script that parses through a file and inserts data into
I have a data file with timestamps in this TEXT format: June 11, 2012
I have a XML file, that looks like this inside: <Data> <INFO> .. ...
I have a data file that looks like the following example. I've added '%'
I have a data file with the # sign as delimiter, that I would
I have a file containing some data (for example, 00927E2B112DB958......). This data is a
I have csv file that has contents like this: 10,53073,0,0,'Y','2008-05-30 21:46:55',0,'2008-05-30 21:48:04',0,53071,2 I want
I have a file data.base which looks like: 1234 XXXX 4321 XXXX 9884 ZZZZ

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.