Ctrl+Enter versus. Clicking Run

56 views (last 30 days)
David on 6 Oct 2013
What is the difference between executing a code with the use of crtl+enter versus clicking run at the top of the toolbar?
[EDITED, Jan, copied from answer section]
Sorry that I wasn't clear.
Sometimes when I use crtl+enter, I receive errors that I would not if I clicked on run. These errors are specific to the code. In one of my codes, I constantly received the error "function is not defined" or something along those lines, but the function WAS defined. I had no problem running this code by clicking run.
  1 Comment
Jan on 6 Oct 2013
Please add important information inside the original question, where readers find them immediately. The section for answers should be reserved for solutions or suggestions. Thanks.
Do the "function not defined" messages concern subfunctions in the currently opened M-file or in its folder? While "Run" or F5 runs the file in its folder, other M-files are found there even if the folder is not part of the Matlab's path.

Sign in to comment.

Answers (2)

Subin Kuttappan Stellal Mary
Edited: Subin Kuttappan Stellal Mary on 9 Dec 2015
Ctrl+Enter execute a block of code (between two lines starting with %%)
Run or 'F5' executes the entire file.

Jan on 6 Oct 2013
I do not know corresponding points in the documentation, but only tried a little bit in the editor:
  1. "Run" or F5 requires the file to be saved
  2. F5 allows to define input arguments
  3. Ctrl-Enter runs the code without saving also.
Do you observe other differences? Perhaps a more useful answer can be given if you explain the problem you have.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by