unable to call function in script
Afficher commentaires plus anciens
I am using Win 10. I have included the folder where my scripts are via Set Path.
Here is an example:
In file InitializeNetwork.m, I have this function:
function nn = InitializeNetwork(architecture) % line #10
... ...
end
================================
From matlab R017a command line, I did these:
>> architecture=[336 100 20];
>> nn = InitializeNetwork(architecture);
Error: File: InitializeNetwork.m Line: 10 Column: 15
Function with duplicate name "InitializeNetwork" cannot be defined.
======================================
Please advice. Thank you.
Réponse acceptée
Plus de réponses (1)
Cam Salzberger
le 31 Août 2017
Sounds like you have multiple functions in the same file named InitializeNetwork. Is there another function with that same name at line 1?
Here's how I reproduced the error:
function nn = InitializeNetwork(architecture)
nn = 10;
end
function nn = InitializeNetwork(architecture)
nn = 3;
end
Calling it with this:
>> n = InitializeNetwork(1)
Error: File: InitializeNetwork.m Line: 4 Column: 15
Function with duplicate name "InitializeNetwork" cannot be defined.
-Cam
2 commentaires
Steven Lord
le 31 Août 2017
If you have the file open in the MATLAB Editor, there should be a red square in the upper-right corner and a red line somewhere below that. If you click on the red line(s) it should take you to the duplicate definition(s) in the file.
Hoe-Phuan Ng
le 1 Sep 2017
Catégories
En savoir plus sur MATLAB Report Generator 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!