unable to call function in script
Show older comments
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.
Accepted Answer
More Answers (1)
Cam Salzberger
on 31 Aug 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 Comments
Steven Lord
on 31 Aug 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
on 1 Sep 2017
Categories
Find more on MATLAB Report Generator 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!