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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:33:09+00:00 2026-05-27T08:33:09+00:00

my question is the title. Why is str2double so slow in matlab as compared

  • 0

my question is the title.

  1. Why is str2double so slow in matlab as compared to a mex function made in C/C++? Does matlab just not have good string handling capabilities?

  2. Can anyone give me some factual reasons as to why a mex function runs so many orders of magnitude faster? I was hoping to do a running time analysis of this difference but I don’t have any concrete reasons from the code for matlab.

  3. Can you explain to me how I would open to file and actually look at the code written for the built in matlab str2double function?

some postings on the topic:

http://www.mathworks.com/matlabcentral/fileexchange/28893-fast-string-to-double-conversion

I don’t understand what the poster means when they try to explain how this function runs more quickly. For instance, what does this mean: (str2doubleq is the mex function made in c++)

“str2doubleq exploits the mex-gateway to use c++ fast string handling capabilities and the std::stringstream properties. The conversion uses same ideas that is used in boost::lexical_cast”

No one can answer this?

  • 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-05-27T08:33:10+00:00Added an answer on May 27, 2026 at 8:33 am

    1) str2double is a pretty complex function that can convert many different formats. I guess that your mex implementation is much simpler and that can explain why it’s faster. Som examples are provided in matlab help:

       str2double('123.45e7')
       str2double('123 + 45i')
       str2double('3.14159')
       str2double('2.7i - 3.14')
       str2double({'2.71' '3.1415'})
       str2double('1,200.34')
    

    2) why mex are faster? Because when you execute a standard m-file script, basically there is a program that will read your program an execute it (an interpreter). So there are two layers. However, when you write a mex-file, you compile it directly in the CPU language, such that it can be run directly by the processor. There is only one layer, so it’s faster. For more details, see the wikipedia article:

    http://en.wikipedia.org/wiki/Interpreted_language

    http://en.wikipedia.org/wiki/Compiled_language

    3) You cannot see the code of str2double because it is compiled. Matworks does not provide the code of this function. You can execute it, but not read it. This is the same for all built-in functions.

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

Sidebar

Related Questions

Excuse the terrible question title. I have this PHP string and want to check
The question title just about says it all. I have a ASP.NET MVC 2
[Apologies if my question title does not accurately describe my problem- if you can
The question title is a bit strange because I'm not exactly sure how to
As question title, caching should be disabled either by: appending unique javascript generated string
Sorry for the bad question title. Let's say that I have DateRange class that
Edit: Changed question title from Does C# allow method overloading, PHP style (__call)? -
Although the question title is duplicate of many discussions, I did not find a
OK, the question title probably isn't the best, but I'm looking for a good
The question title is probably not correct because part of my question is to

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.