Error with function duplicate name where there is only one function.
Ältere Kommentare anzeigen
Hello
Matlab tries to call a function with the name "SegmentBone" as you can see from the example but I get the error of duplicate name and that Matlab cannot define it. There is only one SegmentBone.m in the folder. Why duplicate name?
Error: File: SegmentBone.m Line: 7 Column: 18
Function with duplicate name "SegmentBone" cannot be defined.
Error in Test1 (line 38)
imSeg = SegmentBone(im, 10e6, 0.031);
9 Kommentare
Adam Danz
am 18 Jun. 2019
Make sure your main function name matches the m file name and that you don't have two different functions with the same name within the file. This demo below reproduces your error (saved in a file name SegmentBone.m).
function y= SegmentBone(x)
q = jff(4);
y = x * q;
function q = SegmentBone(x)
q = x+1;
y = SegmentBone(1);
Error: File: SegmentBone.m Line: 7 Column: 14
Function with duplicate name "SegmentBone" cannot be defined.
Stelios Fanourakis
am 18 Jun. 2019
Two quick things;
1) could you show us the results of this?
which SegmentBone -all
2) could you show us the content of segmentBone.m, particularly the code around line 7?
Stelios Fanourakis
am 18 Jun. 2019
Bearbeitet: Stelios Fanourakis
am 18 Jun. 2019
My first "quick thing" doesn't address whether you're using the correct function. It confirms that there are no other files with the same name. Did you run that line? What does it output?
which SegmentBone -all
Also, what version of matlab are you using? If there are any non-comments prior to the first line of code where the function is declared, that would produce the error you're getting (in r2016a or prior).
Stelios Fanourakis
am 18 Jun. 2019
Adam Danz
am 18 Jun. 2019
If you attach SegmentBone.m, Test1.m, 2A.bmp, and any other inputs needed to recreate the problem, I can look into it further.
Stelios Fanourakis
am 18 Jun. 2019
Walter Roberson
am 18 Jun. 2019
You duplicated that into another question. The volunteers are not fond of answering the same query in three different Questions.
Antworten (0)
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!