How to create stable axes on matlab gui

1 view (last 30 days)
I have created a matlab gui panel which is usefull for product configuration. I have too many tabs and in every tab I have some choises with pictures.in first step everything looks perfectly fine. But as you can see in the attachments when I restarted the program gui don't shows the images.. After I've been sure again to everything is o.k. (I click every CreateFcn of every axes) It works again. but only till the next restart. What am I doing wrong?
I write images code in axes_CreateFcn title, for exapmle;
function axes_Elektrischer_a_CreateFcn(hObject, eventdata, handles)
imshow(imread('C:\Users\***\Desktop\akbnamen\bilder\Elektrischer_a.png'));
set(hObject,'tag','axes_Elektrischer_a')
function axes_Elektrischer_b_CreateFcn(hObject, eventdata, handles)
imshow(imread('C:\Users\***\Desktop\akbnamen\bilder\Elektrischer_b.png'));
set(hObject,'tag','axes_Elektrischer_b')
  5 Comments
Geoff Hayes
Geoff Hayes on 11 Apr 2020
You can specify the parent axes as a parameter to imshow (see imshow name value pairs for details). In your case, you would do something like the following in your OpeningFcn:
imshow(imread('C:\Users\***\Desktop\akbnamen\bilder\Elektrischer_a.png'), 'Parent', handles.axes_Elektrischer_a);
imshow(imread('C:\Users\***\Desktop\akbnamen\bilder\Elektrischer_b.png'), 'Parent', handles.axes_Elektrischer_b);
You don't need to set the Tag of the axes as that should already be set with the name of the axes.
fatih orman
fatih orman on 12 Apr 2020
thanks man, works perfectly you are hero. But I can't pick your answer as accepted.

Sign in to comment.

Accepted Answer

Geoff Hayes
Geoff Hayes on 13 Apr 2020
fatih - You can specify the parent axes as a parameter to imshow (see imshow name value pairs for details). In your case, you would do something like the following in your OpeningFcn:
imshow(imread('C:\Users\***\Desktop\akbnamen\bilder\Elektrischer_a.png'), 'Parent', handles.axes_Elektrischer_a);
imshow(imread('C:\Users\***\Desktop\akbnamen\bilder\Elektrischer_b.png'), 'Parent', handles.axes_Elektrischer_b);
You don't need to set the Tag of the axes as that should already be set with the name of the axes.

More Answers (0)

Categories

Find more on Graphics Performance 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!