plotfield.m

来自「解决麦克斯韦的matlab源文件」· M 代码 · 共 34 行

M
34
字号
function plotfield(mesh,vals,titstr)% Creates an arrow plot of a vectorfield whose values are stored% in the vals column vector%% mesh -> Data for 2D unstructured mesh% vals -> column vector whose length must agree with mesh.Nv%if (size(vals,1) ~= 2*mesh.Nv), error('Size mismatch for argument vector'); endif (size(vals,2) ~= 1), error('Vals must be a colun vector'); endif (nargin < 3), titstr = 'Arrowplot of vectorfield'; endhold on;title(titstr);bb = [ 0 0 0 0 ];% 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-');  bb = [ min([ev(1,1),ev(1,2),bb(1)]),...	 max([ev(1,1),ev(1,2),bb(2)]),...	 min([ev(2,1),ev(2,2),bb(3)]),...	 max([ev(2,1),ev(2,2),bb(4)]) ];end% Plot arrowsvx = vals(1:2:2*mesh.Nv,1);vy = vals(2:2:2*mesh.Nv,1);quiver(mesh.vt(:,1),mesh.vt(:,2),vx,vy,0.75,'b-');axis(bb);hold off;

⌨️ 快捷键说明

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