Error with function duplicate name where there is only one function.
显示 更早的评论
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 个评论
Adam Danz
2019-6-18
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
2019-6-18
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
2019-6-18
编辑:Stelios Fanourakis
2019-6-18
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
2019-6-18
Adam Danz
2019-6-18
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
2019-6-18
Walter Roberson
2019-6-18
You duplicated that into another question. The volunteers are not fond of answering the same query in three different Questions.
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!