Question about axes, control group and GUI (GUIDE)

1 Ansicht (letzte 30 Tage)
Pedro Augusto de Castro e Castro
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 Kommentare
Rik
Rik am 9 Jun. 2020
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
Bearbeitet: Pedro Augusto de Castro e Castro am 10 Jun. 2020
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

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Graphics Performance finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by