Matlab - Radio button asociado a multiples funciones en una GUI en matlab

   
Vista:

Radio button asociado a multiples funciones en una GUI en matlab

Publicado por Hector (15 intervenciones) el 21/01/2014 16:43:41
Estimados,

antes que nada agradeceros por toda la ayuda que me habéis brindado anteriormente, me han sido de muchísima utilidad y me permite aprender de todos vosotros.

Os molesto nuevamente porque tengo un problema con un radio button que quiero asociar a múltilples gráficos en una GUI de Matlab. El código que podréis encontrar a continuación, permite que al presionar el botón RUN! de la gui, la misma dibuje 4 gráficos en 2D y uno en 3D. El radio button que encontraréis a la derecha junto con los gráficos en 2D en el recuadro "adjustment, permite variar tanto el color, grosor de la linea como el tipo de línea, solo que ahora lo puedo hacer con solo uno de ellos, el de la esquina superior izquierda. Ahora bien, he intentado asociarlo a los 3 gráficos en 2D restantes, pero no logro hacer que funcione.

Agradecería enormemente vuestra ayuda nuevamente!

Un saludo

Héctor

====================================== Desde aquí el código ============================

function First_Model (varargin)

close all
clear all
clc

figure_color=[0.39 0.99 0.99];
panel_color=[1 1 1];


hFigure= figure('MenuBar','none',...
'Units','Pixels',...
'Color',figure_color,...
'Toolbar','none',...
'Name','First model',...
'resize','off',...
'NumberTitle','off',...
'Position',[1 810 1280 683]);

movegui(hFigure,'center');

warning off MATLAB:uitabgroup:OldVersion % turn off warning

hg=uitabgroup('Parent',hFigure,...
'units','pixels','position',...
[1.5 10 1277 677]);

%------------------------------------------------------Tabs----------------------------------------------------------------%
ht(2)=uitab(hg,'Title','Plott');
%-----------------------------------------------------Panels----------------------------------------------------------------

hPanelB = uipanel(...
'Title','',...
'Fontsize',22,...
'Parent', ht(2),...
'Units','Pixels',...
'BorderWidth',1,...
'Position',[1 1 1263 640],...
'BackgroundColor',panel_color);

%---------------------------------------------------Sub_Panels--------------------------------------------------------------

%## Sub Panels ##%

hSubPanel1 = uipanel('Parent',ht(2),'Units',...
'pixels','Title','Input Parameters','Fontsize',17,...
'BackgroundColor',[1 1 1],'Position',[5.5 194 595 133],...
'BorderWidth',2);

hSubPanel2 = uipanel('Parent',hPanelB,'Units',...
'pixels','Title','Statistics','Fontsize',14,...
'BackgroundColor',[1 1 1],'Position',[600 3 640 615],...
'BorderWidth',2);

hSubPanel3 = uipanel('Parent',hSubPanel2,'Units',...
'pixels','Title','Adjustment','Fontsize',14,...
'BackgroundColor',[1 1 1 ],'Position',[210 230 218 135],...
'BorderWidth',1);

hSubPanel4 = uipanel('Parent',hPanelB,'Units',...
'pixels','Title','3D View','Fontsize',14,...
'BackgroundColor',[1 1 1],'Position',[0.5 3 595 362],...
'BorderWidth',2);

%-------------------------------------------------- Plots ------

%##### TID Analysis Plots--------

hGraph1 = axes('Parent',hSubPanel2,'Units',...
'pixels','Position',[55 420 195 135],'Color',[1 1 1]);

hGraph2 = axes('Parent',hSubPanel2,'Units',...
'pixels','Position',[415 420 195 135],'Color',[1 1 1]);

hGraph3 = axes('Parent',hSubPanel2,'Units',...
'pixels','Position',[55 60 195 135],'Color',[1 1 1]);

hGraph4 = axes('Parent',hSubPanel2,'Units',...
'pixels','Position',[415 60 195 135],'Color',[1 1 1]);

hGraph5 = axes('Parent',hSubPanel4,'Units',...
'pixels','Position',[50 53 465 260],'Color',[1 1 1]);

%-------------------------------------------------Radio Buttons -----------------------------------------------------------------

hRadio = uibuttongroup('Position',[.05,.05,.9,.9],...
'Parent',hSubPanel3,'Units','Normalized');

uicontrol('Style','RadioButton','String',...
'Exponential','FontSize',10,'Position',[0.05,0.70,0.46,0.22],...
'Parent',hRadio,'Tag','esp','Units','normalized');

uicontrol('Style','RadioButton','String','PDF',...
'FontSize',10,'Position',[0.58,0.70,0.46,0.22],...
'Parent',hRadio,'Tag','pdf','Units','normalized');

uicontrol('Style','RadioButton','String','CDF',...
'FontSize',10,'Position',[0.05,0.50,0.46,0.22],...
'Parent',hRadio,'Tag','cdf','Units','normalized');

uicontrol('Style','RadioButton','String','1-PDF',...
'FontSize',10,'Position',[0.58,0.50,0.46,0.22],...
'Parent',hRadio,'Tag','1-pdf','Units','normalized');

%------------------------------------------------- Tuner frames-----------------------------------------------------------------

hcolorPopup = uicontrol('Parent',hSubPanel3,'Units',...
'normalized','BackgroundColor',[1 1 1],'FontSize',15,...
'ForegroundColor',[0 0 0],'Position',[0.08 0.33 0.48 0.12],...
'String',{ 'Color'; 'Red'; 'Yellow'; 'Green'; 'Blue'; 'Magenta'; 'Black'; },...
'Style','popupmenu','Value',1,'Callback',@colorPopup_Callback);

hlineStylePopup = uicontrol('Parent',hSubPanel3,'Units',...
'normalized','BackgroundColor',[1 1 1],'FontSize',15,...
'ForegroundColor',[0 0 0],'Position',[0.08 0.14 0.48 0.12],...
'String',{ 'Line'; 'Solid'; 'Dotted'; 'Dashed'; 'DotDash'; 'none' },...
'Style','popupmenu','Value',1,'Callback',@lineStylePopup_Callback);

hlineWidthEditBox = uicontrol('Parent',hSubPanel3,'Units',...
'normalized','BackgroundColor',[1 1 1],'FontSize',15,...
'ForegroundColor',[0 0 0],'Position',[0.58 0.08 0.35 0.32],...
'String','','Style','edit','Callback',@lineWidthEditBox_Callback);

hLineWidth = uicontrol('Parent',hSubPanel3,'Units',...
'normalized','BackgroundColor',[1 1 1],'FontSize',10,...
'ForegroundColor',[0 0 0],'HorizontalAlignment','left',...
'Position',[0.65 0.33 0.20 0.10],'String','L.Width:','Style','text');


%######## Analysis Push Buttons---

hMainPushButton = uicontrol('Parent',hSubPanel1,'Units',...
'normalized','Position',[0.32 0.42 0.32 0.38],'Style','Pushbutton',....
'String',' Run!','FontSize',25,'Callback',@MainPushButton_Callback);


handle_list=...
[hFigure,hg,ht(2),hSubPanel1,...
hSubPanel2,hSubPanel3,hSubPanel4,hGraph1,...
hGraph2,hGraph3,hGraph4,hGraph5,...
hRadio,hcolorPopup,hlineStylePopup,hlineWidthEditBox,...
hLineWidth,hMainPushButton];
set(handle_list,'Units','normalized');



%------------------------------------------------------- EVALUATION FUNCTION BEGINS -------------------------------

% % --- Executes on button press in run_rad_cal.
function MainPushButton_Callback(hObject, eventdata)

x = 1:80;
o = 1-poisscdf(x,65);
p = 1-poisspdf(x,2);
q = 1-poisscdf(x,13);
r = poisscdf(x,43);

axes(hGraph1);
plot(x,o,'Tag','Plot');xlabel('Number of elements','FontName','Helvetica','FontSize', 18,'fontweight','bold',...
'string','XLabel')
ylabel('F(t)','FontName','Helvetica','FontSize',18);grid on;set(gca,'FontSize',18)

axes(hGraph2);
plot(x,p,'Tag','Plot');xlabel('Number of elements','FontName','Helvetica','FontSize', 18)
ylabel('P(t)','FontName','Helvetica','FontSize',18);grid on;set(gca,'FontSize',18)


axes(hGraph3);
plot(x,q,'Tag','Plot');xlabel('Number of elements','FontName','Helvetica','FontSize', 18)
ylabel('C(t)','FontName','Helvetica','FontSize',18);grid on;set(gca,'FontSize',18)

axes(hGraph4);
plot(x,r,'Tag','Plot');xlabel('Number of elements','FontName','Helvetica','FontSize', 18)
ylabel('S(t)','FontName','Helvetica','FontSize',18);grid on;set(gca,'FontSize',18)


axes(hGraph5);
for k=1:100;
for l=1:6;
z(k,l) = 1-(poisscdf(k,64.*l));
end;
end;

surf(z)

c= colorbar('YTickLabel', {'Lowest', 'Low', 'Medium','High','Highest'},'YTick', [0.03 0.27 0.5 0.75 0.96]);
x1=get(gca,'position');x=get(c,'Position');x(3)=0.02;set(c,'Position',x);set(gca,'position',x1)
text(0.185,1.1,'Standard Model','units', 'Normalized', 'VerticalAlignment', 'Top','FontSize', 18)
xlabel('time in years','FontName','Helvetica','FontSize', 18)
ylabel('Number of XY','FontName','Helvetica','FontSize', 18)
zlabh = get(gca,'ZLabel');
set(zlabh,'Position', get(zlabh,'Position')+[0.1])
zlabel ('Confidence level','FontName','Helvetica','FontSize', 18)
grid on
shading interp
set(gca,'FontSize',18)
set(gcf,'color','w');


end

function colorPopup_Callback(hObject,eventdata)
colors=get(hcolorPopup,'string');
index=get(hcolorPopup,'value');
color=colors{index};
switch color
case 'Red'
h=findobj(hGraph1,'Tag','Plot');set(h,'color','r')
case 'Blue'
h=findobj(hGraph1,'Tag','Plot');set(h,'color','b')
case 'Yellow'
h=findobj(hGraph1,'Tag','Plot');set(h,'color','y')
case 'Green'
h=findobj(hGraph1,'Tag','Plot');set(h,'color','g')
case 'Magenta'
h=findobj(hGraph1,'Tag','Plot');set(h,'color','m')
case 'Black'
h=findobj(hGraph1,'Tag','Plot');set(h,'color','k')
end
end

function lineStylePopup_Callback(hObject,eventdata)
styles=get(hlineStylePopup,'string');
index=get(hlineStylePopup,'value');
linestyle=styles{index};
switch linestyle
case 'Solid'
h=findobj(hGraph1,'Tag','Plot');set(h,'linestyle','-')
case 'Dotted'
h=findobj(hGraph1,'Tag','Plot');set(h,'linestyle',':')
case 'Dashed'
h=findobj(hGraph1,'Tag','Plot');set(h,'linestyle','--')
case 'DotDash'
h=findobj(hGraph1,'Tag','Plot');set(h,'linestyle','-.')
case 'none'
h=findobj(hGraph1,'Tag','Plot');set(h,'linestyle','none')
end
end

function lineWidthEditBox_Callback(hObject,eventdata)
width=str2double(get(hlineWidthEditBox,'string'));
h=findobj(hGraph1,'Tag','Plot'); set(h,'linewidth',width)
end
%------------------------------------------------------- EVALUATION FUNCTION ENDS -------------------------------

end
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder