필터 지우기
필터 지우기

Cannot find function figure1_KeyPressFcn in GUI code file

조회 수: 2 (최근 30일)
Stephen
Stephen 2017년 8월 9일
답변: Kai Tanaka 2019년 8월 1일
In the GUIDE editor, when I right click on the figure and go to add a callback, pressing the KeyPressFcn callback selection yields a msgbox error which says "Cannot find function figure1_KeyPressFcn in GUI code file C:". Note that there is no path given after "C:". When a keypress event occurs during runtime, there is an error printed to console which states "error using feval ... undefined function 'figure1_KeyPressFcn' ..."
How should I go about fixing this error?
  댓글 수: 3
Stephen
Stephen 2018년 1월 19일
Richard, no, I never did figure out how to fix this. I ended up re-creating the GUI from scratch in guide and then copying in the relevant code. I think it happened originally because I copied a .fig file I'd edited in parallel with the code (trying to sync the UI changes with the latest code file by just replacing the .fig file). But no easy answer, I think it's just corrupted file(s)
Richard Moyse Fenning
Richard Moyse Fenning 2018년 1월 19일
Thanks Stephen.
Following an answer to a different question, I did 'save as' on the fig and it seems to work OK now. I'm not 100% sure the two are related though :)

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

답변 (1개)

Kai Tanaka
Kai Tanaka 2019년 8월 1일
I also ran into this issue and was able to find a way to resolve it. It appears the error can be caused by creating the callback code and then deleting it. In order to get GUIDE to regenerate the code:
  1. Rename the 'Tag' of the offending GUI element inside Inspector
  2. Save the GUI
  3. Right click the element in the figure, and select 'view callbacks'
The code was now generated in my GUI .m file and the error went away.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by