Professional Documents
Culture Documents
Gui Assignment
Gui Assignment
f = figure('Visible','off','Name','YY"s assignment','Position',[360,500,550,350]);
ha = axes('Units','Pixels','Position',[10,60,200,185]);
hpopup = uicontrol('Style','popupmenu',...
'String',{'Axis parallel hyper-ellipsoid function',...
'Griewangk"s function'},...
'Position',[300,300,200,25],...
'Callback',{@popup_menu_Callback});
ph1 = uipanel('Parent',pha,'Title','Mesh',...
'TitlePosition','centertop',...
'Position',[.02 .05 .3 .9]);
ph2 = uipanel('Parent',pha,'Title','Surf',...
'TitlePosition','centertop',...
'Position',[.35 .05 .3 .9]);
ph3 = uipanel('Parent',pha,'Title','Contour',...
'TitlePosition','centertop',...
'Position',[.68 .05 .3 .9]);
hmesh = uicontrol(ph1,'Style','pushbutton','String','Mesh',...
'Position',[5 65 70 25],...
'Callback',{@meshbutton_Callback});
hmeshc = uicontrol(ph1,'Style','pushbutton','String','Meshc',...
'Position',[5 35 70 25],...
'Callback',{@meshcbutton_Callback});
hmeshz = uicontrol(ph1,'Style','pushbutton','String','Meshz',...
'Position',[5,5,70,25],...
'Callback',{@meshzbutton_Callback});
hsurf = uicontrol(ph2,'Style','pushbutton','String','Surf',...
'Position',[5,65,70,25],...
'Callback',{@surfbutton_Callback});
hsurfc = uicontrol(ph2,'Style','pushbutton','String','Surfc',...
'Position',[5,35,70,25],...
'Callback',{@surfcbutton_Callback});
hcontour = uicontrol(ph3,'Style','pushbutton',...
'String','Contour',...
'Position',[5,65,70,25],...
'Callback',{@contourbutton_Callback});
tb2 = uicontrol(phb,'Style','togglebutton',...
'String','Zoom',...
'Value',0,'Position',[40,8,70,25],...
'Callback',{@togglebutton2_Callback});
tb3 = uicontrol(phb,'Style','togglebutton',...
'String','Pan',...
'Value',0,'Position',[80,8,70,25],...
'Callback',{@togglebutton3_Callback});
align([hsurf,hsurfc],'Center','None');
align([hmesh,hmeshc,hmeshz],'Center','None');
align([hpopup,htext1,pha,phb],'Center','None');
align([tb1,tb2,tb3],'Fixed',15,'top');
set([f,hpopup,htext1,pha,ph1,ph2,ph3,hmesh,...
hmeshc,hmeshz,hsurf,hsurfc,hcontour,...
phb,tb1,tb2,tb3],...
'Units','normalized');
[Xa,Ya]= meshgrid(-5.12:0.1:5.12);
[Xb,Yb]= meshgrid(-600:10:600);
function11d_data = Xa.^2;
function12d_data = Xa.^2 +(2.*Ya.^2);
function21d_data = ((Xb.^2)/4000)-cos(Xb)+1;
function22d_data = (((Xb.^2)./4000)+((Yb.^2)./4000))-
((cos(Xb)).*(cos(Yb./sqrt(2))))+1;
current_data = function12d_data;
subplot(2,2,1);
plot(Xa,function11d_data,'rx');
title ('1D Graph');ylabel('Y-axis');xlabel('X-axis');
subplot(2,2,3);
mesh(current_data);
title ('2D Graph');ylabel('Y-axis');xlabel('X-axis');
zlabel('Z-axis');
movegui(f,'center')
set(f,'Visible','on');
function popup_menu_Callback(source,eventdata,handles)
str = get(source, 'String');
val = get(source,'Value');
switch str{val};
case'Axis parallel hyper-ellipsoid function'
current_data = function12d_data;
subplot(2,2,1);
plot(Xa,function11d_data,'rx');
title ('1D Graph');ylabel('Y-axis');xlabel('X-axis');
subplot(2,2,3);
mesh(current_data);
title ('2D Graph');ylabel('Y-axis');xlabel('X-axis');
zlabelG('Z-axis');
case 'Griewangk"s function'
current_data = function22d_data;
subplot(2,2,1);
plot(Xb,function21d_data,'rx');
title ('1D Graph');ylabel('Y-axis');xlabel('X-axis');
subplot(2,2,3);
mesh(current_data);
title ('2D Graph');ylabel('Y-axis');xlabel('X-axis');
zlabel('Z-axis');
end
end
function meshbutton_Callback(source,eventdata)
subplot(2,2,3);
mesh(current_data);
title ('2D Graph');ylabel('Y-axis');xlabel('X-axis');
zlabel('Z-axis');
end
function meshcbutton_Callback(source,eventdata)
subplot(2,2,3);
meshc(current_data);
title ('2D Graph');ylabel('Y-axis');xlabel('X-axis');
zlabel('Z-axis');
end
function meshzbutton_Callback(source,eventdata)
subplot(2,2,3);
meshz(current_data);
title ('2D Graph');ylabel('Y-axis');xlabel('X-axis');
zlabel('Z-axis');
end
function surfbutton_Callback(source,eventdata)
subplot(2,2,3);
surf(current_data);
title ('2D Graph');ylabel('Y-axis');xlabel('X-axis');
zlabel('Z-axis');
end
function surfcbutton_Callback(source,eventdata)
subplot(2,2,3);
surfc(current_data);
title ('2D Graph');ylabel('Y-axis');xlabel('X-axis');
zlabel('Z-axis');
end
function contourbutton_Callback(source,eventdata)
subplot(2,2,3);
contour(current_data);ylabel('Y-axis');xlabel('X-axis');
title ('Countour Graph');
zlabel('Z-axis');
end
function togglebutton1_Callback(source,eventdata)
button_state = get(source,'Value');
if button_state == get(source,'Max')
rotate3d on
zoom off
pan off
elseif button_state == get(source,'Min')
rotate3d off
zoom out
end
end
function togglebutton2_Callback(source,eventdata)
button_state = get(source,'Value');
if button_state == get(source,'Max')
rotate3d off
zoom on
pan off
elseif button_state == get(source,'Min')
zoom off
zoom out
end
end
function togglebutton3_Callback(source,eventdata)
button_state = get(source,'Value');
if button_state == get(source,'Max')
rotate3d off
zoom of
pan on
elseif button_state == get(source,'Min')
pan off
zoom out
end
end
end