What does this error for hist mean?

조회 수: 2 (최근 30일)
Douglas Brenner
Douglas Brenner 2016년 11월 5일
편집: Walter Roberson 2016년 11월 5일
Attempt to execute SCRIPT hist as a function:
/Users/douglasbrenner/Documents/MATLAB/hist.m
Error in extractedge (line 33)
hist(Mean)

채택된 답변

Image Analyst
Image Analyst 2016년 11월 5일
In extractedge.m you're calling
something = hist(mean);
However there are two very bad things with that.
First, you have a script called hist.m and it's trying to call hist.m and pass it mean, but hist.m is a script, not a function so it cannot take any arguments.
Second, you're either passing the built-in mean() function to your script (bad, unless your m-file is a function that is expecting a function instead of a variable), OR you created a variable called mean, which is very very bad since that would blow away the built-in mean function.
TO FIX:
Rename your hist.m to something like hist_test.m. And in extractedge.m do something like
thisMean = mean(someVector);
hist_test;
Now if you want to pass thisMean to hist_test.m, then you need to make hist_test.m a function instead of a script and you can do this by adding a function line with the name of the m-file. So the first line would be this:
function hist_test(theMean)
% Then somehow do something with theMean in the function.
  댓글 수: 1
Douglas Brenner
Douglas Brenner 2016년 11월 5일
Thanks. I didn't accept my own answer.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Douglas Brenner
Douglas Brenner 2016년 11월 5일
Got it. hist.m is now myhist.m
  댓글 수: 1
Image Analyst
Image Analyst 2016년 11월 5일
That wasn't the only problem. See my answer.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by