⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gui_grid1.m

📁 关于MATLAB 的m文件。其详细介绍了怎么样应用MATLAB的应用。大家可以互相学习下
💻 M
📖 第 1 页 / 共 3 页
字号:
temp_x = plane_s_dot(3,1) ;temp_y = plane_s_dot(3,2) ;temp_z = plane_s_dot(3,3);plane_s_line_num(2) =temp_x+1+temp_z*m*(n+1)+temp_y*m;temp_x = plane_s_dot(1,1) ;temp_y = plane_s_dot(1,2) ;temp_z = plane_s_dot(1,3);plane_s_line_num(3) =(p+1)*m*(n+1)+temp_z*n*(m+1)+temp_y*(m+1)+1+temp_x;temp_x = plane_s_dot(2,1) ;temp_y =plane_s_dot(2,2) ;temp_z =plane_s_dot(2,3);plane_s_line_num(4) =(p+1)*m*(n+1)+temp_z*n*(m+1)+temp_y*(m+1)+1+temp_x;%输出线的编号set(handles.liness,'String',strcat('',num2str(plane_s_line_num')));%将组成面的线用红色点作出for   z=zz    for   y=yy:(yy+1)     for    k=xx:xx       x=k:0.025:k+1;       plot3(x,y,z,'r');       hold on;     end    endendfor   z=zz    for   x=xx:(xx+1)     for    e=yy:yy       y=e:0.025:e+1;       plot3(x,y,z,'r');       hold on;     end    endendhold on; %平行于YOZ面的平面elseif plane_s_num > m*(p+1)*n && plane_s_num<=m*(p+1)*n+p*(m+1)*nzz = fix((plane_s_num-1-m*(p+1)*n)/((m+1)*n));yy = fix((plane_s_num-1-m*(p+1)*n-zz*(m+1)*n)/(m+1));xx = fix(plane_s_num-1-m*(p+1)*n -zz*(m+1)*n - yy*(m+1));plane_s_dot = zeros(4,3);plane_s_dot_num = zeros(4,1);plane_s_dot(1,:) = [xx,yy,zz]';plane_s_dot(2,:) = [xx,yy+1,zz]';plane_s_dot(3,:) = [xx,yy,zz+1]';plane_s_dot(4,:) = [xx+1,yy+1,zz+1]';plane_s_line_num = zeros(4,1);temp_x =plane_s_dot(1,1);temp_y =plane_s_dot(1,2);temp_z =plane_s_dot(1,3);plane_s_line_num(1) =m*(n+1)*(p+1)+temp_z*(m+1)*n+temp_y*(m+1)+temp_x+1;temp_x = plane_s_dot(3,1);temp_y = plane_s_dot(3,2);temp_z = plane_s_dot(3,3);plane_s_line_num(2) =m*(n+1)*(p+1)+temp_z*(m+1)*n+temp_y*(m+1)+temp_x+1;         temp_x = plane_s_dot(1,1);temp_y = plane_s_dot(1,2);temp_z = plane_s_dot(1,3);plane_s_line_num(3) =m*(n+1)*(p+1)+n*(m+1)*(p+1)+temp_z*(m+1)*(n+1)+temp_y*(m+1)+temp_x+1;temp_x = plane_s_dot(2,1);temp_y =plane_s_dot(2,2);temp_z =plane_s_dot(2,3);plane_s_line_num(4) =m*(n+1)*(p+1)+n*(m+1)*(p+1)+temp_z*(m+1)*(n+1)+temp_y*(m+1)+temp_x+1;set(handles.liness,'String',strcat('',num2str(plane_s_line_num')));for   x=xx    for   y=yy:(yy+1)     for    k=zz:zz       z=k:0.025:k+1;       plot3(x,y,z,'r');       hold on;     end    endendfor   x=xx    for   z=zz:(zz+1)     for    e=yy:yy       y=e:0.025:e+1;       plot3(x,y,z,'r');       hold on;     end    endendhold on;%平行于XOZ面的平面else plane_s_num > m*(p+1)*n+p*(m+1)*n && plane_s_num<= m*p*(n+1)+n*p*(m+1)+m*(p+1)*nzz = fix((plane_s_num-1-m*(p+1)*n-p*(m+1)*n)/(m*(n+1)));yy = fix((plane_s_num-1-m*(p+1)*n-p*(m+1)*n-zz*m*(n+1))/m);xx = fix(plane_s_num-1-m*(p+1)*n-p*(m+1)*n -zz*m*(n+1) - yy*m);plane_s_dot = zeros(4,3);plane_s_dot(1,:) = [xx,yy,zz]';plane_s_dot(2,:) = [xx+1,yy,zz]';plane_s_dot(3,:) = [xx,yy,zz+1]';plane_s_dot(4,:) = [xx+1,yy,zz+1]';plane_s_line_num = zeros(4,1);temp_x =plane_s_dot(1,1);temp_y =plane_s_dot(1,2);temp_z =plane_s_dot(1,3);plane_s_line_num(1) =temp_x+1+temp_z*m*(n+1)+temp_y*m;temp_x = plane_s_dot(3,1);temp_y = plane_s_dot(3,2);temp_z = plane_s_dot(3,3);plane_s_line_num(2) =temp_x+1+temp_z*m*(n+1)+temp_y*m; temp_x = plane_s_dot(1,1);temp_y = plane_s_dot(1,2);temp_z = plane_s_dot(1,3);plane_s_line_num(3) =m*(n+1)*(p+1)+n*(m+1)*(p+1)+temp_z*(m+1)*(n+1)+temp_y*(m+1)+temp_x+1;temp_x = plane_s_dot(2,1);temp_y =plane_s_dot(2,2);temp_z =plane_s_dot(2,3);plane_s_line_num(4) =m*(n+1)*(p+1)+n*(m+1)*(p+1)+temp_z*(m+1)*(n+1)+temp_y*(m+1)+temp_x+1;set(handles.liness,'String',strcat('',num2str(plane_s_line_num')));for   y=yy    for   x=xx:(xx+1)     for    k=zz:zz       z=k:0.025:k+1;       plot3(x,y,z,'r');       hold on;     end    endendfor  y=yy    for   z=zz:(zz+1)     for    e=xx:xx      x=e:0.025:e+1;       plot3(x,y,z,'r');       hold on;     end    endendhold on;endfunction line_s_num_Callback(hObject, eventdata, handles)% hObject    handle to line_s_num (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 line_s_num as text%        str2double(get(hObject,'String')) returns contents of line_s_num as a double% --- Executes during object creation, after setting all properties.function line_s_num_CreateFcn(hObject, eventdata, handles)% hObject    handle to line_s_num (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 line_dots.function line_dots_Callback(hObject, eventdata, handles)% hObject    handle to line_dots (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)%读取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;%调用画图函数重新做图以消除可能存在的以前的操作结果draw(m,n,p);%读取uicontrol中line_s_num的值line_s_num=str2num(get(handles.line_s_num,'String'));if line_s_num>m*(n+1)*(p+1)+(m+1)*n*(p+1)+(m+1)*(n+1)*p        set(handles.dotss,'String',strcat('',num2str('error')));elseif line_s_num<=0        set(handles.dotss,'String',strcat('',num2str('error')));        %平行于X轴的线elseif line_s_num<=m*(p+1)*(n+1)     %计算直线的块坐标zz = fix((line_s_num-1)/(m*(n+1)));yy = fix((line_s_num-1-zz*m*(n+1))/m);xx = fix(line_s_num-1 - zz*m*(n+1) - yy*m);%建立并计算线的端点坐标矩阵line_s_dot = zeros(2,3);line_s_dot(1,:) = [xx,yy,zz]';line_s_dot(2,:) = [xx+1,yy,zz]';%建立并计算线的端点编号矩阵line_s_dot_num = zeros(2,1);temp_x =line_s_dot(1,1) ;temp_y =line_s_dot(1,2) ;temp_z =line_s_dot(1,3);line_s_dot_num(1) = temp_x+1+temp_z*(m+1)*(n+1)+temp_y*(m+1);temp_x = line_s_dot(2,1) ;temp_y = line_s_dot(2,2) ;temp_z = line_s_dot(2,3);line_s_dot_num(2) =temp_x+1+temp_z*(m+1)*(n+1)+temp_y*(m+1);%输出线的端点编号set(handles.dotss,'String',strcat('',num2str(line_s_dot_num')));%将线用红色点作出for   z=zz    for   y=yy:yy     for    k=xx:xx       x=k:0.025:k+1;       plot3(x,y,z,'r');       hold on;     end    endendhold on;   %平行于Y轴的线elseif line_s_num > m*(p+1)*(n+1) && line_s_num<= m*(p+1)*(n+1)+(p+1)*(m+1)*nzz = fix((line_s_num-1-m*(p+1)*(n+1))/((m+1)*n));yy = fix((line_s_num-1-m*(p+1)*(n+1)-zz*(m+1)*n)/(m+1));xx = fix(line_s_num-1-m*(p+1)*(n+1) -zz*(m+1)*n - yy*(m+1));line_s_dot = zeros(2,3);line_s_dot_num = zeros(2,1);line_s_dot(1,:) = [xx,yy,zz]';line_s_dot(2,:) = [xx,yy+1,zz]';temp_x =line_s_dot(1,1);temp_y =line_s_dot(1,2);temp_z =line_s_dot(1,3);line_s_dot_num(1) =temp_x+1+temp_z*(m+1)*(n+1)+temp_y*(m+1);temp_x = line_s_dot(2,1);temp_y = line_s_dot(2,2);temp_z = line_s_dot(2,3);line_s_dot_num(2) =temp_x+1+temp_z*(m+1)*(n+1)+temp_y*(m+1);set(handles.dotss,'String',strcat('',num2str(line_s_dot_num')));for   x=xx    for   z=zz:zz     for    k=yy:yy       y=k:0.025:k+1;       plot3(x,y,z,'r');       hold on;     end    endendhold on;   %平行于Z轴的线else line_s_num > m*(p+1)*(n+1)+(p+1)*(m+1)*n && line_s_num<=m*(n+1)*(p+1)+(m+1)*n*(p+1)+(m+1)*(n+1)*pzz = fix((line_s_num-1-m*(p+1)*(n+1)-(p+1)*(m+1)*n)/((m+1)*(n+1)));yy = fix((line_s_num-1-m*(p+1)*(n+1)-(p+1)*(m+1)*n-zz*(m+1)*(n+1))/(m+1));xx = fix(line_s_num-1-m*(p+1)*(n+1)-(p+1)*(m+1)*n-zz*(m+1)*(n+1) - yy*(m+1));line_s_dot = zeros(2,3);line_s_dot(1,:) = [xx,yy,zz]';line_s_dot(2,:) = [xx,yy,zz+1]';line_s_dot_num = zeros(2,1);temp_x =line_s_dot(1,1);temp_y =line_s_dot(1,2);temp_z =line_s_dot(1,3);line_s_dot_num(1) =temp_x+1+temp_z*(m+1)*(n+1)+temp_y*(m+1);temp_x = line_s_dot(2,1);temp_y =line_s_dot(2,2);temp_z = line_s_dot(2,3);line_s_dot_num(2) =temp_x+1+temp_z*(m+1)*(n+1)+temp_y*(m+1);set(handles.dotss,'String',strcat('',num2str(line_s_dot_num')));for   y=yy    for   x=xx:xx     for    k=zz:zz       z=k:0.025:k+1;       plot3(x,y,z,'r');       hold on;     end    endendendfunction coordinates_Callback(hObject, eventdata, handles)% hObject    handle to coordinates (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 coordinates as text%        str2double(get(hObject,'String')) returns contents of coordinates as a double% --- Executes during object creation, after setting all properties.function coordinates_CreateFcn(hObject, eventdata, handles)% hObject    handle to coordinates (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 dot_coordinates.function dot_coordinates_Callback(hObject, eventdata, handles)% hObject    handle to dot_coordinates (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)%读取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;%调用画图函数重新做图以消除可能存在的以前的操作结果draw(m,n,p);%读取uicontrol中dot_s_num的值dot_s_num=str2num(get(handles.dot_s_num,'String'));if dot_s_num>(m+1)*(n+1)*(p+1)        set(handles.coordinates,'String',strcat('',num2str('error')));elseif dot_s_num<=0        set(handles.coordinates,'String',strcat('',num2str('error')));else dot_s_num<=(m+1)*(n+1)*(p+1)    %计算点的块坐标zz = fix((dot_s_num-1)/((m+1)*(n+1)));yy = fix((dot_s_num-1-zz*(m+1)*(n+1))/(m+1));xx = fix(dot_s_num-1 - zz*(m+1)*(n+1) - yy*(m+1));dot = [xx,yy,zz]';%输出点的坐标set(handles.coordinates,'String',strcat('',num2str(dot'))); %在图中利用点的坐标找到点并用汉字“点”标记r=0.1;[x,y,z]=sphere; mesh(r*x+xx,r*y+yy,r*z+zz);endfunction planess_Callback(hObject, eventdata, handles)% hObject    handle to planess (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 planess as text%        str2double(get(hObject,'String')) returns contents of planess as a double% --- Executes during object creation, after setting all properties.function planess_CreateFcn(hObject, eventdata, handles)% hObject    handle to planess (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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -