?? 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 + -