📄 gui_mesh2d.m
字号:
function varargout = GUI_Mesh2d(varargin)
% GUI_MESH2D M-file for GUI_Mesh2d.fig
% GUI_MESH2D, by itself, creates a new GUI_MESH2D or raises the existing
% singleton*.
%
% H = GUI_MESH2D returns the handle to a new GUI_MESH2D or the handle to
% the existing singleton*.
%
% GUI_MESH2D('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI_MESH2D.M with the given input arguments.
%
% GUI_MESH2D('Property','Value',...) creates a new GUI_MESH2D or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before GUI_Mesh2d_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to GUI_Mesh2d_OpeningFcn via varargin.
%
% *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_Mesh2d
% Last Modified by GUIDE v2.5 24-Oct-2007 21:26:27
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GUI_Mesh2d_OpeningFcn, ...
'gui_OutputFcn', @GUI_Mesh2d_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if 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_Mesh2d is made visible.
function GUI_Mesh2d_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 command line arguments to GUI_Mesh2d (see VARARGIN)
% Choose default command line output for GUI_Mesh2d
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GUI_Mesh2d wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = GUI_Mesh2d_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 output from handles structure
varargout{1} = handles.output;
% --------------------------------------------------------------------
function File_New_Callback(hObject, eventdata, handles)
% hObject handle to File_New (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function File_Open_Callback(hObject, eventdata, handles)
% hObject handle to File_Open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function File_Import_Boundary_Callback(hObject, eventdata, handles)
%该函数用于导入王老师系统中的边界条件,这个边界用来生成计算网格
[filename, pathname] = uigetfile({'*.txt', '文本文件(*.txt)';'*.dat','文本文件(*.dat)';});
if(filename == 0)
return;
end
filename = [pathname filename];
%读取其中的文件,并为每一段分配空间
fid=fopen(filename,'r');
fscanf(fid,'%s ',2);%先丢掉‘一般地形区域’ ‘。。。。地形’
n=fscanf(fid,'%d',1);%得到该局域的段数(由几个子区域构成)
node=[];%定义一个空的节点数组,该数组用来存储所有节点的坐标
connect=[];%各个点的连接关系
nn=1;nt=0;%nt表示现在这个线段再总结点node中开头点的索引
pn=[];%每段的点数
while(~feof(fid) && nn<=n)
na=fscanf(fid,'%d',1);%获得每一段的点数
connect=[connect;(nt+1:na-1+nt)',(nt+2:na+nt)'];
np=(fscanf(fid,'%f %f',[2 na]))';
node=[node;np];
nn=nn+1;%这里表示高程点就不必要了,只读取边界线数据
nt=nt+na;
pn=[pn,nt];
end
%在该图形界面上绘制出边界线
hold on
a=0;
for i=1:n
plot(node(a+1:pn(i),1),node(a+1:pn(i),2),'k-');
a=a+pn(i);
end
hold off
[p,t] = mesh2d(node,connect);
% --------------------------------------------------------------------
function File_Callback(hObject, eventdata, handles)
% hObject handle to File (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -