필터 지우기
필터 지우기

How do I fix the error Function definitions are not permitted at the prompt or in scripts.

조회 수: 4 (최근 30일)
whenever I write the command function imageChoice_callback(hObject,eventdata). Encounter an error Function definitions are not permitted at the prompt or in scripts. please suggest me how do i fix it.

답변 (2개)

Sean de Wolski
Sean de Wolski 2011년 12월 12일
Write in in an editor file and save it as the title of function, e.g:
function hello_world(hObject,evt)
fprintf(2,'Hello World!');
end
saved in hello_world.m
  댓글 수: 3
Walter Roberson
Walter Roberson 2011년 12월 12일
Apply the solution Sean gave: write the sections that start with "function" into individual files.
The part before the first "function" line should be written into EZresize.m

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


Fangjun Jiang
Fangjun Jiang 2011년 12월 12일
편집: John Kelly 2015년 2월 26일
The message said so. You are not allowed to define a function in the command line or in a script file.
You need to create a separate .m file, where the first line, you define "function imageChoice_callback(hObject,eventdata)" and then save the file as imageChoice_callback.m.
Or, the function name sounds like belonging to a .m file for a GUI application. You should add this function in the .m file for that GUI application. The first line of that .m file should also be a "function ..." line. Otherwise, that .m file is called a script. You are not allowed to define a function in a script.
  댓글 수: 1
Daniel Shub
Daniel Shub 2011년 12월 12일
What about your other campaign ..
http://www.mathworks.com/matlabcentral/answers/7691-please-vote-if-you-do-not-want-to-have-m-function-in-m-script

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by