📄 gui_grid1.m
字号:
function varargout = gui_grid1(varargin)%GUI_GRID1 M-file for gui_grid1.fig% GUI_GRID1, by itself, creates a new GUI_GRID1 or raises the existing% singleton*.%% H = GUI_GRID1 returns the handle to a new GUI_GRID1 or the handle to% the existing singleton*.%% GUI_GRID1('Property','Value',...) creates a new GUI_GRID1 using the% given property value pairs. Unrecognized properties are passed via% varargin to gui_grid1_OpeningFcn. This calling syntax produces a% warning when there is an existing singleton*.%% GUI_GRID1('CALLBACK') and GUI_GRID1('CALLBACK',hObject,...) call the% local function named CALLBACK in GUI_GRID1.M with the given input% arguments.%% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one% instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help gui_grid1% Last Modified by GUIDE v2.5 07-May-2009 09:35:58% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @gui_grid1_OpeningFcn, ... 'gui_OutputFcn', @gui_grid1_OutputFcn, ... 'gui_LayoutFcn', [], ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});else gui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before gui_grid1 is made visible.function gui_grid1_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin unrecognized PropertyName/PropertyValue pairs from the% command line_dot_s_num (see VARARGIN)% Choose default command line_dot_s_num output for gui_grid1%设置各uicontrol的默认值set(handles.x_edit,'String','3');set(handles.y_edit,'String','3');set(handles.z_edit,'String','3');set(handles.a_edit,'String','1');set(handles.b_edit,'String','1');set(handles.c_edit,'String','1');set(handles.dot_s_num,'String','1');set(handles.cube_s_num,'String','1');set(handles.plane_s_num,'String','1');set(handles.line_s_num,'String','1');handles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes gui_grid1 wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line_dot_s_num.function varargout = gui_grid1_OutputFcn(hObject, eventdata, handles)% varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line_dot_s_num output from handles structurevarargout{1} = handles.output;function x_edit_Callback(hObject, eventdata, handles)% hObject handle to x_edit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of x_edit as text% str2double(get(hObject,'String')) returns contents of x_edit as a double% --- Executes during object creation, after setting all properties.function x_edit_CreateFcn(hObject, eventdata, handles)% hObject handle to x_edit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');endfunction a_edit_Callback(hObject, eventdata, handles)% hObject handle to a_edit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of a_edit as text% str2double(get(hObject,'String')) returns contents of a_edit as a double% --- Executes during object creation, after setting all properties.function a_edit_CreateFcn(hObject, eventdata, handles)% hObject handle to a_edit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');endfunction y_edit_Callback(hObject, eventdata, handles)% hObject handle to y_edit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of y_edit as text% str2double(get(hObject,'String')) returns contents of y_edit as a double% --- Executes during object creation, after setting all properties.function y_edit_CreateFcn(hObject, eventdata, handles)% hObject handle to y_edit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');endfunction b_edit_Callback(hObject, eventdata, handles)% hObject handle to b_edit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of b_edit as text% str2double(get(hObject,'String')) returns contents of b_edit as a double% --- Executes during object creation, after setting all properties.function b_edit_CreateFcn(hObject, eventdata, handles)% hObject handle to b_edit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');endfunction z_edit_Callback(hObject, eventdata, handles)% hObject handle to z_edit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of z_edit as text% str2double(get(hObject,'String')) returns contents of z_edit as a double% --- Executes during object creation, after setting all properties.function z_edit_CreateFcn(hObject, eventdata, handles)% hObject handle to z_edit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');endfunction c_edit_Callback(hObject, eventdata, handles)% hObject handle to c_edit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of c_edit as text% str2double(get(hObject,'String')) returns contents of c_edit as a double% --- Executes during object creation, after setting all properties.function c_edit_CreateFcn(hObject, eventdata, handles)% hObject handle to c_edit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end% --- Executes on button press in play.function play_Callback(hObject, eventdata, handles)%读取uicontrol中x,y,z,a,b,c的值并计算各坐标轴单位长度的个数x=str2num(get(handles.x_edit,'String'));y=str2num(get(handles.y_edit,'String'));z=str2num(get(handles.z_edit,'String'));a=str2num(get(handles.a_edit,'String'));b=str2num(get(handles.b_edit,'String'));c=str2num(get(handles.c_edit,'String'));m=x/a;n=y/b;p=z/c;%统计点线面体的个数g=(m+1)*(n+1)*(p+1);h=m*(n+1)*(p+1)+(m+1)*n*(p+1)+(m+1)*(n+1)*p;j=m*p*(n+1)+n*p*(m+1)+m*(p+1)*n;l=m*n*p;%显示点线面体的个数set(handles.dots,'String',strcat('',num2str(g)));set(handles.lines,'String',strcat('',num2str(h)));set(handles.planes,'String',strcat('',num2str(j)));set(handles.cubes,'String',strcat('',num2str(l)));%调用作图函数draw (m,n,p);%清屏并作三维立体六面体图function draw(m,n,p)cla;%d=moviein(m*(n+1)*(p+1)+n*(m+1)*(p+1)+p*(n+1)*(m+1))for z=0:p for y=0:n for k=0:(m-1) x=k:0.025:k+1; plot3(x,y,z); hold on; %d(:,k+1+y*k+y*k*z)=getframe; end endendfor z=0:p for x=0:m for e=0:(n-1) y=e:0.025:e+1; plot3(x,y,z); hold on; %d(:,m*(n+1)*(p+1)+e+1+x*e+e*x*z)=getframe; end endendfor y=0:n for x=0:m for f=0:(p-1) z=f:0.025:f+1; plot3(x,y,z); hold on; %d(:,m*(n+1)*(p+1)+n*(m+1)*(p+1)+f+1+f*x+f*x*y)=getframe; end endend%movie(d);xlabel('x','FontSize',15) %坐标轴名称标注ylabel('y','FontSize',15) %坐标轴名称标注zlabel('z','FontSize',15) %坐标轴名称标注% hObject handle to play (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% --- Executes on button press in close_pushbutton.function close_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to close_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)closefunction dots_Callback(hObject, eventdata, handles)% hObject handle to dots (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of dots as text% str2double(get(hObject,'String')) returns contents of dots as a double% --- Executes during object creation, after setting all properties.function dots_CreateFcn(hObject, eventdata, handles)% hObject handle to dots (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');endfunction lines_Callback(hObject, eventdata, handles)% hObject handle to lines (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of lines as text% str2double(get(hObject,'String')) returns contents of lines as a double% --- Executes during object creation, after setting all properties.function lines_CreateFcn(hObject, eventdata, handles)% hObject handle to lines (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');endfunction planes_Callback(hObject, eventdata, handles)% hObject handle to planes (see GCBO)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -