tags:

views:

64

answers:

2

In MATLAB, why does the file have to be saved prior to running ?

I often try quick snippets of code, which I could also easily run also on the Command Window line by line. So, why when I run them through the editor, I have to save them first ?

Can this behaviour be changed, maybe ?

+3  A: 

my guess would be that when you run your program, the matlab interpreter run it from the disk and not from the IDE buffer. so if you don't save the file it wouldn't run the correct code.

Omry
+4  A: 

You can use cell mode in the editor placing %% before your code. See also Cell menu in the editor. Once you create cells, you can run them one by one pressing Ctrl-Enter. You don't need to save the file. However you cannot use editor's debugging features (breakpoints, etc).

Video tutorial

yuk
Ahh! Very nice. Yes, that'll do! (I just want to stop littering my folders with files a.m, aa.m, aaa.m, b.m, bba.m, bbdg.m, fdsa.m and the like :)
ldigas
Note you can also just highlight parts of the code and press F9 (or shift-F7 on OS X) to evaluate parts that are not in cell mode.
Jonas

related questions