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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:30:22+00:00 2026-05-26T14:30:22+00:00

I read in the documentation that I can use the statement echo on; to

  • 0

I read in the documentation that I can use the statement echo on; to have MATLAB print the statements it executes. However, I am having difficulties making this work inside a function.

For example:

function do_something(foo)

a   = 2;
echo on;
foo = foo+1;
disp('This is a test');
foo = foo+3;

end

If I call do_something(foo) from the command window, I was expecting to see something like:

foo = foo+1;
disp('This is a test');
This is a test
foo = foo+3;

However, in the example above, all MATLAB prints is:

this is a test

which is not what I was expecting.

Update

As @Phonon explains below, echo on is only for scripts (sorry I missed that!). However, I read in the documentation that I can activate echo for a given function as follows:

echo fcnname on

So my question now is, is there a way to activate echo for a function using some variation of the syntax above so that I do this (call echo) inside a function? (the variable that holds the function name in this case would be provided by mfilename)

Update 2:

As far as I understand it is not possible to activate echo for a particular function inside the actual function. Among other things, it seems that MATLAB needs to know beforehand if the function has to run in "echo mode" to avoid using JIT.

  • 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-26T14:30:23+00:00Added an answer on May 26, 2026 at 2:30 pm

    According to Matlab documentation, i.e. help echo,

    ECHO ON turns on echoing of commands inside Script-files.

    It will not work inside functions. To make it work for functions, according to that same help file,

    ECHO ON ALL turns on the echoing of commands inside any Function-files that are currently in memory (i.e., the functions returned by INMEM).

    ECHO OFF ALL turns them all off.

    Update:

    In order to find which function you’re in currently, the best way I see of doing it is by calling dbstack. Goes somewhat as follows:

    [S,I] = dbstack;
    funcName = S.name;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read the documentation that states that "given the type of the enum,
I have read documentation for functions such as values and define-values that return and
In the documentation I have read that I don't need to release the NSOperation
I've read in the Android 3.0 documentation that it is now possible to use
I have read in the documentation that there are 4 or 5 ways in
I have looked, searched, and read documentation and can't really find anything about this.
I read somewhere in the Microsoft documentation that the content of the ASP.NET's web.config
While searching for some functions in C++ standard library documentation I read that push
Having read the documentation of Java's String class, it doesn't appear to support popping
I have read the documentation on this and I think I understand. An AutoResetEvent

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.