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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:12:22+00:00 2026-06-03T17:12:22+00:00

I might have misunderstood something.. but I expected the running of a code in

  • 0

I might have misunderstood something.. but I expected the running of a code in the editor and in the command window to be the same..

I have the following code in the editor

display('  ');
display('script');
fac = @(n) prod(1:n);

n=20;
display(['- use of anonymous function: fac = @(n) prod(1:n); with n = ' num2str(n)]);
tic; fac(n); toc;

display(['- use of build in MatLab function: factorial(); with n = ' num2str(n)]);
tic; factorial(n); toc;

before I run (is that called compiled or execute?) I quickly type in the same command in the command window. Which gives me this:

strange performance time

So all of a sudden the factorial function in the editor got a boost when it comes to performance.. What just happened?

  • 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-03T17:12:24+00:00Added an answer on June 3, 2026 at 5:12 pm

    First, the calculation you are trying to measure is too quick to get anything like an accurate reading. It is way below the measurement noise you get when using tic/toc because of other processes and activity on the system. To get more accurate measures repeat the calculation many times… (I would repeat the calculation so it takes 10-20 seconds).

    Second, there is indeed a difference between code typed interactively and in a script. I think the JIT only runs for code run from a script or function m-file, where and not for stuff running in the interpreter (but I am struggling to find a reference for this now – I will add if I find it).

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

Sidebar

Related Questions

The same question might have been asked but I didn't find any solutions available
I might have pretty basic question about regex. I have the following regex, which
I have a situation where I might have multiple instances of a program running
We have some ancient Delphi code (might have even originated as Turbo Pascal code)
curious if anyone might have some insight in how I would do the following
I think it might have been asked before but i was unable to find
I think I might have done something right, headByRating and headByName both refer to
I think I might have greatly misunderstood the usage of gluperspective() and require help.
I might have misunderstood the meaning of base.OnLoad(e); My understanding was that this statement
This might have very obvious solution but I'm afraid I cannot find out how

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.