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

📄 plotedfield.m

📁 解决麦克斯韦的matlab源文件
💻 M
字号:
function plotedfield(mesh,ev,titstr)% Quiver plot of edge element vector field on midpoints of triangles%% mesh -> data structure for 2D unstructured grid% ev -> Column vector of length mesh.Ne containing the edge dofs%if (size(ev,1) ~= mesh.Ne), error('Size mismatch for argument vector'); endif (size(ev,2) ~= 1), error('ev must be a column vector'); endif (nargin < 3), titstr = 'Center values of edge element v.f.'; endcntr = zeros(mesh.Nt,2);vals = zeros(mesh.Nt,2);for i=1:mesh.Nt% Global indices of vertices and edges of triangle  vidx = mesh.trv(i,:);  eidx = mesh.tre(i,:);% Compute information about geometry of current triangle  tgeo = mesh.vt(vidx,:)';  x = tgeo(1,:);  y = tgeo(2,:);  c = sum(tgeo')/3.0;  vofs = tgeo-[c' c' c'];  cntr(i,:) = c;  d = (x(2)-x(1))*(y(3)-y(1))-(x(3)-x(1))*(y(2)-y(1));  area = abs(d)/2;% Get value of edge element function at center of gravity% (Uses gradients of barycentric coordinate functions)  G = 1/(2*area)*[y(2)-y(3) , y(3)-y(1) , y(1)-y(2);...		  x(3)-x(2) , x(1)-x(3) , x(2)-x(1)];  vals(i,:) = ([G(:,3)-G(:,2) , G(:,1)-G(:,3) , G(:,2)-G(:,1)]/3*...	       (ev(eidx,1).*mesh.treo(i,:)'))';endhold on;title(titstr);% Plot boundary of domainebd_idx  = find(mesh.ebfl(:,1) ~= 0);for i=ebd_idx'  ev = [mesh.vt(mesh.ep(i,1),:)' mesh.vt(mesh.ep(i,2),:)'];   plot(ev(1,:),ev(2,:),'k-');endquiver(cntr(:,1),cntr(:,2),vals(:,1),vals(:,2),0.75,'b-');hold off;

⌨️ 快捷键说明

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