Createfcn is not working during displaying an image in background?

1 view (last 30 days)
Hi,
I have a simple code to display an image in GUI background, but I cannot make it visible.
I just did the same thing with this video,
What can be the problem?
In addition I realized that matlab is not executing the createfcn callback of axes object.
Thanks in advance
Rafet
  2 Comments
Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh on 31 Aug 2014
Edited: Salaheddin Hosseinzadeh on 31 Aug 2014
Hi Rafet,
Put the lines of the code related to displaying the code plz.
You should have something similar to this
plot(handles.axis1,Xdata,Ydata);
CreateFcn executes once, and that's only when the object is created so it won't execute repetitively just because the axis is viewed.
Rafet
Rafet on 31 Aug 2014
thanks for your answer, I did not know that createfcn executes only once
to overcome this problem I put my code under openingfcn
it works

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 31 Aug 2014
Edited: Image Analyst on 31 Aug 2014
Your best bet is to just ignore all GUIDE CreateFcn() functions. Don't put any code into them. You can put code into the OpeningFcn, which executes once upon startup. Or you can put code into the OutputFcn() which executes once upon startup, after the OpeningFcn has run and after the FUI window has been made visible. OutputFcn also executes when the GUI shuts down. I really suggest you put lines like these into the functions to see when, and in what order, they are run:
fprintf('Now running OpeningFcn....\n'); % or OutputFcn or whatever...
Note, there are some lines of code that must be put into OutputFcn such as those to maximize the GUI window:
FigurejFrame = get(handle(gcf),'JavaFrame');
FigurejFrame.setMaximized(true);
Thanks to Yair for the above code http://undocumentedmatlab.com/

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!