How to call a own function in other mfile?
Afficher commentaires plus anciens
Good morning,
I create my own function
function z = myfunc (x,y)
z = x+y;
end
I have to use it into a mfile how can do it ?
Regards
Réponse acceptée
Plus de réponses (1)
John D'Errico
le 3 Juil 2024
Modifié(e) : John D'Errico
le 3 Juil 2024
Did you save it on your search path? (Do you know what your search path is?) Spend some time reading the help for tools like addpath, savepath, pathtool, etc.
help pathtool
Do NOT try to save that file into the directories supplied with MATLAB. DO NOT DO THAT. Use your own directory.
Once that is done, now just call it like you would any other function,
x = 12;
y = 1:3;
z = myfunc(x,y)
And you can use that function in any other function you write now too.
1 commentaire
Antonio
le 3 Juil 2024
Catégories
En savoir plus sur Search Path 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!