How to bookmark a piece of code
Afficher commentaires plus anciens
Hi everyone,
I wonder if it's possible to bookmark pieces of code to make kinds of pre-scripts in a menu for example.
For example, can i creat a bookmark of the following script to not have to rewrite this every time i wont to plot a figure ?
figure();
plot();
title('');
xlabel('');
ylabel('');
legend;
Thanks
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 5 Déc 2020
2 votes
To set bookmarks in an editor, you can type control-F2. Then you can type F2 to move cyclically through the bookmarks. At this time there is no bookmark panel to let you see bookmarked lines and go there directly.
To reuse code snippets, I do it two ways. If they are just partial snippets, I put them all into a file called "common_code.m". Then if I need a particular snippet of code, like say to ask the user for a filename, I just go to that m-file and copy the snippet I need.
If the snippet is a fully functioning function, I put them all into a folder called "Utilities" and make sure that folder is on my path. Then anytime I need that function, I simply call it.
Or if it's a function that really only applies to your one specific program, then you can put it in your program as its own function, like down at the end of all the code.
Catégories
En savoir plus sur Variables dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!