GUI - using "handles.tag" with variable tag
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi everybody,
I used GUIDE to built a GUI with several axes taged as data1,data2,data3,... In the opening function I use
set(handles.tagsofallaxes,'visible','off');
to display them all.
Now I inserted checkboxes which get a unique plot and place this plot in the next free axes. For example: first plot in data1, second in data2, maybe I uncheck afterwards the checkbox for plot1 and data1 will be free again. when I check for plot 3 after this, it should appear in data1 which was empty at this moment.
For this I coded a function that gives me the next free axes. Output of the function is a string (data1,data2,data3,...).
I don't get how I can use the output to show my plot on the axes.
nextfreeaxes = counter('position'); % saves tag of next free axes in string
axes(handles.nextfreeaxes)
gives error: Reference to non-existent field 'nextfreeaxes'.
When I build a switch case everything is fine. But its not the way I want to do this.
nextfreeaxes = counter('position'); % saves tag of next free axes in string
switch nextfreeaxes
case 'data1'
axes(handles.data1)
case 'data2'
axes(handles.data2)
case 'data3'
axes(handles.data3)
case 'data4'
axes(handles.data4)
end
I know that handles is a struct, but I don't get how to have access to its parts in the way I need it. I am a beginner in coding so please help me.
댓글 수: 0
채택된 답변
Walter Roberson
2016년 5월 1일
handles.(nextfreeaxes)
However, I suggest that you just create a vector of all of the values,
axhandles = [handles.data1, handles.data2, handles.data3];
Then you can index them
axes(axhandles(idx))
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!