How to create a "macro" button on Matlab editor
Show older comments
The short version of my request is:
Is there a way to have a macro that combines two commands, 1. fclose all 2. exit debug mode(shift+F5)
and make it available on the editor as a button, just like there are buttons for "exit debug mode (shift+F5)", "Continue (F5)" etc.
Here is the long version:
I use Matlab to digest a datafile and display certain outputs as images. I open the datafile (txt) outside a for loop, read a bunch of lines from it at every iteration, and display certain computed outputs in a image. I close the file (using fclose) only after the for loop is over.
Most of the time, I only run a few iterations of the for loop and then press exit (Shift+F5) to stop the run. But this does not execute the "fclose(fid)" command at the end of the file. Hence, the original output file is still being "used" by Matlab as far as other programs are concerned. In order to release the file, every time I have to type "fclose all" in the command window, which is annoying. I am wondering whether I can combine "fclose all, followed by exit (shift+F5)" commands and create a macro that I access on my editor window.
Answers (1)
Walter Roberson
on 2 Oct 2012
0 votes
To solve the issue of closing the file, have you considered using an onCleanup() ?
1 Comment
Nilanjan
on 3 Oct 2012
Edited: Walter Roberson
on 3 Oct 2012
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!