Is there a way to modify default function template

17 vues (au cours des 30 derniers jours)
lewww
lewww le 31 Mai 2021
Commenté : lewww le 1 Juin 2021
When I use the New > Function button and name the created file it generates a default function code with the appropriate name. The generated function has 2 default input variables and output variables and some useless code copying the inputs to the output. Whenever I create a function like this I have two options
  1. Remove/rename the relevant sections of the function (input, output, code inside)
  2. Delete the entire function and type it out from scratch
Both options are annoying, especially doing it every time in a larger project. Is there a way to modify this default function creation. I would like to keep the matching names but rather have something like this
function [] = AssignedName()
end
  5 commentaires
John D'Errico
John D'Errico le 31 Mai 2021
Modifié(e) : John D'Errico le 31 Mai 2021
Apparently, the idea is not one that has been deemed important enough to do something about. You can always submit an enhancement request. Surely, it does not take that much effort to select a block of text, and click on the delete key. Are you creating that many thousands of new files, that this is a serious problem? Personally, having written many thousands of m-files over the years, one would think it would drive me crazy, IF it was really an issue. Not so.
And really, the link that Geoff shows does provide a simple way to populate a new file as you like it. What about that is inadequate?
lewww
lewww le 1 Juin 2021
"Apparently, the idea is not one that has been deemed important enough to do something about."
Here are a few file exchange entries addressing exactly this:
I will definitely make a request. I suspect there are many others having this issue but they do nothing and live with this inadequate software. The problem is that if I want to call functions from the command line I have to create function files. This forces me that for every little script I create and test I need to create new functions. The functions come with this stupid template having unnecessary input, output variables and code inside. What is their purpose? To showcase absolute beginners how to have input and output variables? How to assign the input to the output? How to write documentation?
Let's contrast it with say Visual Studio. On creating a new class for example, we get the bare minimum. But even if someone wants a something extra there are templates.

Connectez-vous pour commenter.

Réponses (1)

Jan
Jan le 31 Mai 2021
  1 commentaire
lewww
lewww le 31 Mai 2021
Thank you for the reference. But this is not what I'm looking for. I would like to change the built in ".template" files for new functions.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Function Creation dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by