이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Question about axes, control group and GUI (GUIDE)
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello,
I have a few questions:
1. I have a GUI with several axes and plots. I would like to make a controul group with radio buttons to control which plots (and axes) are shown. So, I'll have two buttons and half of the axes will be shown at a time. When the user selects the other button, the axes that are displayed will disapear, and the other half will be displayed. When tha user selects another option on the control group, all the info on the axes should disapear, label, title, legend, axis ticks, etc.
2. I also have two buttons, left and right, to control which axes are being shown. This button must consider which set of axes are displayed (defined by the control group). I could make it work considering just one set of axes (ignoring the other half and also the control group).
3. As you can see in tha figure below, there's two axis ticks being shown. I don't know why that is.

4. To get the selected button I did this:
handles.conv = get(handles.show_conv.SelectedObject,'String');
if strcmp(handles.conv, 'Inversor')
....
elseif strcmp(handles.conv, 'Retificador')
....
end
5. Also, when the simulation (thet will get the variables to plot) is running all the plot appears baing plotted, and when the simulation stops only the one I set to be the top appears. I would like, if possible, to not show the plots when they are being plotted, only when I select them via the left and right button. If I could post a video, this would be easier to understand.
Another thing, what may cause an error that only happens the first time I run the program?
Any ideas?
Thanks!
댓글 수: 9
Tommy
2020년 6월 4일
What code are you using to hide axes which should be hidden?
You can tell plot() to make an invisible plot, e.g.
p = plot(axes_handle, X, Y, 'Visible', 'off');
Rik
2020년 6월 4일
You could also actually use your own idea: create two axes and set the Visible property to on or off when appropriate.
Pedro Augusto de Castro e Castro
2020년 6월 4일
Thanks for your inputs.
I have 30 axes, that I set their visibility accordingly. For exemple:
set(handles.graph_1, 'Visible', 'on'); % 'Perdas nos Transistores, Indutores e Totais - Otimização do Volume'
set(handles.graph_2, 'Visible', 'off'); % 'Volume dos Indutores, Dissipadores e Total - Otimização do Volume'
set(handles.graph_3, 'Visible', 'off'); % 'Peso dos Indutores, Dissipadores e Total - Otimização do Volume'
set(handles.graph_4, 'Visible', 'off'); % 'Perdas nos Transistores, Indutores e Totais - Otimização do Peso'
set(handles.graph_5, 'Visible', 'off'); % 'Volume dos Indutores, Dissipadores e Total - Otimização do Peso'
set(handles.graph_6, 'Visible', 'off'); % 'Peso dos Indutores, Dissipadores e Total - Otimização do Peso'
set(handles.graph_7, 'Visible', 'off'); % 'Perdas nos Transistores, Indutores e Totais - Otimização das Perdas'
set(handles.graph_8, 'Visible', 'off'); % 'Volume dos Indutores, Dissipadores e Total - Otimização das Perdas'
set(handles.graph_9, 'Visible', 'off'); % 'Peso dos Indutores, Dissipadores e Total - Otimização das Perdas'
set(handles.graph_10, 'Visible', 'off'); % 'Rendimento x Densidade de Potência Volumétrica - Otimização do Volume e Diferentes Ripples'
set(handles.graph_11, 'Visible', 'off'); % 'Rendimento x Densidade de Potência Mássica - Otimização do Volume e Diferentes Ripples'
set(handles.graph_12, 'Visible', 'off'); % 'Rendimento x Densidade de Potência Volumétrica - Otimização do Peso e Diferentes Ripples'
set(handles.graph_13, 'Visible', 'off'); % 'Rendimento x Densidade de Potência Mássica - Otimização do Peso e Diferentes Ripples'
set(handles.graph_14, 'Visible', 'off'); % 'Rendimento x Densidade de Potência Volumétrica - Otimização das Perdas e Diferentes Ripples'
set(handles.graph_15, 'Visible', 'off'); % 'Rendimento x Densidade de Potência Mássica - Otimização das Perdas e Diferentes Ripples'
Rik
2020년 6월 4일
That looks difficult to handle. Do you have a reason for not putting those axes (or line?) handles in an array?
Tommy
2020년 6월 4일
Note that plotting on a set of axes may reset all axes properties except for units and position (meaning, invisible axes will be made visible) depending on the value of the NextPlot property. You can use hold on to avoid this. But as far as I can tell, a plot will show even on invisible axes unless you make the plot invisible also:
ax = axes('Visible', 'off');
hold(ax, 'on') % so axes remain invisible after plotting
plot(ax, 1:10) % plot still shows
Rik
2020년 6월 4일
You can put all handles that should be set to Visible in an array together. The set function will accept arrays of handles to mixed types, as long as all the properties you're trying to set exist in each object.
Pedro Augusto de Castro e Castro
2020년 6월 4일
When I plot in one of the axes I do something like this:
axes(handles.graph_12);
cla reset; % Do a complete and total reset of the axes.
if ~isempty(handles.graph_12)
hold(handles.graph_12,'on');
for k = 1 : length(delta_i_inv)
txt = num2str(delta_i_inv(k));
scatter(handles.graph_12, [handles.PesoResults_inv(k).Ripple.DensidadePotenciaVol], [handles.PesoResults_inv(k).Ripple.Rendimento], 'DisplayName',txt,'Tag',"Ripple: " +delta_i_inv(k)*100+ " [%]");
end
legend(handles.graph_12);
xlabel(handles.graph_12, 'Densidade de Potência [kW/dm³]');
ylabel(handles.graph_12, 'Rendimento');
title(handles.graph_12, 'Rendimento x Densidade de Potência Volumétrica do Inversor - Otimização do Peso e Diferentes Ripples');
handles.graph_12.Tag = 'ParetoV_Peso_Inv';
end
Do you mean doing something like this?
handles.allAxes = [handles.graph_1, handles.graph_2, handles.graph_3, handles.graph_4, handles.graph_5, handles.graph_6, handles.graph_7, handles.graph_8, handles.graph_9, handles.graph_10, handles.graph_11, handles.graph_12, handles.graph_13, handles.graph_14, handles.graph_15];
Rik
2020년 6월 9일
Since it is not clear what exactly your edit of your question is: could you summarize the edit? What is the main remaining issue?
Pedro Augusto de Castro e Castro
2020년 6월 10일
편집: Pedro Augusto de Castro e Castro
2020년 6월 10일
I solved some of those problems. Right now what I can't understand is: I have two sets of 15 axes each. I have a ButtonDownFcn for all of them, so when I click on one of the plots, a custom data tip will show up. In the first set, everything is fine, I can click on whichever axes that it'll work. However, for the second set, only the last axes works (axes 30). The others I can't even click on them.
I coppied the code for the first set to the second, and changed some variables. Do you have any idea of what might be happening?
EDIT: To exemply, I'll plot the code for two axes (axes 30 and 29). The first one works fine, but the second doesn't
Plotting:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Axes 30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
axes(handles.graph_30);
% cla reset; % Do a complete and total reset of the axes.
% axes('Visible', 'off');
% set(gca,'XTick',[], 'YTick', [])
if ~isempty(handles.graph_30)
hold(handles.graph_30,'on');
min_axis_x = 10000;
min_axis_y = 10000;
max_axis_x = 0;
max_axis_y = 0;
for k = 1 : length(delta_i_ret)
txt = num2str(delta_i_ret(k));
scatter(handles.graph_30, [handles.PerdasResults_ret(k).Ripple.DensidadePotenciaPeso], [handles.PerdasResults_ret(k).Ripple.Rendimento], 'DisplayName',txt,'Tag',"Ripple: " +delta_i_ret(k)*100+ " [%]");
min_axis_x_aux = min([handles.PerdasResults_ret(k).Ripple.DensidadePotenciaPeso])
min_axis_x = min(min_axis_x, min_axis_x_aux)
min_axis_y_aux = min([handles.PerdasResults_ret(k).Ripple.Rendimento])
min_axis_y = min(min_axis_y, min_axis_y_aux)
max_axis_x_aux = max([handles.PerdasResults_ret(k).Ripple.DensidadePotenciaPeso])
max_axis_x = max(max_axis_x, max_axis_x_aux)
max_axis_y_aux = max([handles.PerdasResults_ret(k).Ripple.Rendimento])
max_axis_y = max(max_axis_y, max_axis_y_aux)
end
legend(handles.graph_30);
axis([min_axis_x max_axis_x min_axis_y max_axis_y])
xticks([min_axis_x:(max_axis_x - min_axis_x) / 10 :max_axis_x]);
yticks([min_axis_y:(max_axis_y - min_axis_y) / 10 :max_axis_y]);
xlabel(handles.graph_30, 'Densidade de Potência [kW/kg]');
ylabel(handles.graph_30, 'Rendimento');
title(handles.graph_30, 'Rendimento x Densidade de Potência Mássica do Retificador - Otimização das Perdas e Diferentes Ripples');
handles.graph_30.Tag = 'ParetoM_Perdas_Ret';
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Axes 30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Axes 29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
axes(handles.graph_29);
% cla reset; % Do a complete and total reset of the axes.
% set(gca,'XTick',[], 'YTick', [])
% axes('Visible', 'off');
if ~isempty(handles.graph_29)
hold(handles.graph_29,'on');
min_axis_x = 10000;
min_axis_y = 10000;
max_axis_x = 0;
max_axis_y = 0;
for k = 1 : length(delta_i_ret)
txt = num2str(delta_i_ret(k));
scatter(handles.graph_29, [handles.PerdasResults_ret(k).Ripple.DensidadePotenciaVol], [handles.PerdasResults_ret(k).Ripple.Rendimento], 'DisplayName',txt,'Tag',"Ripple: " +delta_i_ret(k)*100+ " [%]");
min_axis_x_aux = min([handles.PerdasResults_ret(k).Ripple.DensidadePotenciaVol])
min_axis_x = min(min_axis_x, min_axis_x_aux)
min_axis_y_aux = min([handles.PerdasResults_ret(k).Ripple.Rendimento])
min_axis_y = min(min_axis_y, min_axis_y_aux)
max_axis_x_aux = max([handles.PerdasResults_ret(k).Ripple.DensidadePotenciaVol])
max_axis_x = max(max_axis_x, max_axis_x_aux)
max_axis_y_aux = max([handles.PerdasResults_ret(k).Ripple.Rendimento])
max_axis_y = max(max_axis_y, max_axis_y_aux)
end
legend(handles.graph_29);
axis([min_axis_x max_axis_x min_axis_y max_axis_y])
xticks([min_axis_x:(max_axis_x - min_axis_x) / 10 :max_axis_x]);
yticks([min_axis_y:(max_axis_y - min_axis_y) / 10 :max_axis_y]);
xlabel(handles.graph_29, 'Densidade de Potência [kW/dm³]');
ylabel(handles.graph_29, 'Rendimento');
title(handles.graph_29, 'Rendimento x Densidade de Potência Volumétrica do Retificador - Otimização das Perdas e Diferentes Ripples');
handles.graph_29.Tag = 'ParetoV_Perdas_Ret';
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Axes 29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Calling the update function:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Axes 30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- Executes on mouse press over axes background.
function graph_30_ButtonDownFcn(hObject, eventdata, handles) % 'Rendimento x Densidade de Potência Mássica - Otimização das Perdas e Diferentes Ripples'
% hObject handle to graph_15 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
datacursormode(handles.figMainWindow, 'on') %on
handles.dcm = datacursormode(handles.figMainWindow);
set(handles.dcm,'UpdateFcn',@(t,e) myupdatefcn(t,e, handles.PerdasResults_ret, hObject));
% set(handles.dcm,'UpdateFcn',@(t,e) myupdatefcn(t,e, handles.PerdasResults_ret));
% set(handles.dcm,'UpdateFcn',@(t,e) myupdatefcn(t,e, handles.PerdasResults_inv, hObject));
% handles.currentPoint = get(hObject,'CurrentPoint');
% handles.axesForCurrentPoint = hObject;
guidata(hObject, handles);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Axes 30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Axes 29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- Executes on mouse press over axes background.
function graph_29_ButtonDownFcn(hObject, eventdata, handles) % 'Rendimento x Densidade de Potência Volumétrica - Otimização das Perdas e Diferentes Ripples'
% hObject handle to graph_14 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
datacursormode(handles.figMainWindow, 'on') %on
handles.dcm = datacursormode(handles.figMainWindow);
set(handles.dcm,'UpdateFcn',@(t,e) myupdatefcn(t,e, handles.PerdasResults_ret, hObject));
% set(handles.dcm,'UpdateFcn',@(t,e) myupdatefcn(t,e, handles.PerdasResults_ret));
guidata(hObject, handles);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Axes 29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The update function:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Axes 30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'ParetoM_Perdas_Ret'
handles = guidata(hObject);
d = pdist2([event.Target.XData(:), event.Target.YData(:)], event.Position);
[~, minIdx] = min(d);
% assignin('base','d',d)
% assignin('base','minIdx',minIdx)
DispName = str2double(event.Target.DisplayName)
% assignin('base','DispName',DispName)
index_graph = find(deltaI == DispName);
% assignin('base','index',index)
% assignin('base','minIdx',minIdx)
% pos = get(event,'Position');
dts = get(event.Target,'Tag');
% assignin('base','dts',dts)
% [~,j]= find( xdata==pos(1) & ydata==pos(2) );
handles.currentPoint = [(event.Target.XData(minIdx)) (event.Target.YData(minIdx))];
handles.currentPointFsw = info(index_graph).Ripple(minIdx).Fsw;
handles.currentPointDeltaI = DispName;
handles.currentPointResults= info;
handles.currentPointInfo = 'M_Perdas';
guidata(hObject, handles);
txt = {dts + " - Retificador",...
['Densidade de Potência: ', num2str(event.Target.XData(minIdx)), ' [kW/kg]'],...
['Rendimento: ', num2str(100 * event.Target.YData(minIdx)), ' [%]'],...
['Frequência de Chaveamento: ', num2str(info(index_graph).Ripple(minIdx).Fsw), ' [Hz]' ],...
['Material do Indutor: ', info(index_graph).Ripple(minIdx).Material]...
['Dissipador: ', info(index_graph).Ripple(minIdx).PartNumberHS]...
['Comprimento do Dissipador: ', num2str(info(index_graph).Ripple(minIdx).CompHS), ' [dm]']...
['Configuração: ', info(index_graph).Ripple(minIdx).ConfigHS]};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Axes 30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Axes 29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'ParetoV_Perdas_Ret'
d = pdist2([event.Target.XData(:), event.Target.YData(:)], event.Position);
[~, minIdx] = min(d);
DispName = str2double(event.Target.DisplayName);
% assignin('base','DispName',DispName)
index_graph = find(deltaI == DispName);
% assignin('base','index',index)
% assignin('base','minIdx',minIdx)
% pos = get(event,'Position');
dts = get(event.Target,'Tag');
% assignin('base','dts',dts)
handles.currentPoint = [(event.Target.XData(minIdx)) (event.Target.YData(minIdx))];
handles.currentPointFsw = info(index_graph).Ripple(minIdx).Fsw;
handles.currentPointDeltaI = DispName;
handles.currentPointResults= info;
handles.currentPointInfo = 'V_Perdas';
guidata(hObject, handles);
% [~,j]= find( xdata==pos(1) & ydata==pos(2) );
txt = {dts + " - Retificador",...
['Densidade de Potência: ', num2str(event.Target.XData(minIdx)), ' [kW/dm³]'],...
['Rendimento: ', num2str(100 * event.Target.YData(minIdx)), ' [%]'],...
['Frequência de Chaveamento: ', num2str(info(index_graph).Ripple(minIdx).Fsw), ' [Hz]' ],...
['Material do Indutor: ', info(index_graph).Ripple(minIdx).Material]...
['Dissipador: ', info(index_graph).Ripple(minIdx).PartNumberHS]...
['Comprimento do Dissipador: ', num2str(info(index_graph).Ripple(minIdx).CompHS), ' [dm]']...
['Configuração: ', info(index_graph).Ripple(minIdx).ConfigHS]};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Axes 29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Thanks in advance
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Animation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
