注册 登录
Simwe仿真论坛(forum.simwe.com),CAE/CAD/CAM/,FEA/FEM/有限元分析论坛---(手机验证注册) 返回首页

跑上岸晒太阳的鱼滴空间 ... ... ... https://home.simwe.com/?134479 [收藏] [复制] [分享] [RSS] 黄花无主今自容,暗落疏篱曲径中;乞得金钱换脂粉,一生颜色逐西风。

日志

matlab 表达电场特性

已有 1871 次阅读2012-1-10 23:10 |个人分类:Matlab| Matlab, 电场

1.网上找到一段脚本
[x,y]=meshgrid(-2:0.1:2,-2:0.1:2); 
z=1./sqrt((x-1).^2+y.^2+0.01)+1./sqrt((x+1).^2+y.^2+0.01); %此处加0.01的原因是不能让分母为0
[dx,dy]=gradient(z); 
contour(x,y,z,12);
hold on;
quiver(x,y,dx,dy);
xx=[linspace(-2,2,10),2*linspace(1,1,10),linspace(-2,2,10),-2*linspace(1,1,10),.01*linspace(1,1,10),-.01*linspace(1,1,10)]; yy=[2*linspace(1,1,10),linspace(-2,2,10),-2*linspace(1,1,10),linspace(-2,2,10),linspace(-2,2,10),linspace(-2,2,10)]; streamline(x,y,dx,dy,xx,yy) 

2.复制到matlab运行得到以下图形


2.了解各部分函数.
2.1

meshgrid
Generate X and Y arrays for 3-D plots 
Syntax
[X,Y] = meshgrid(x,y)
[X,Y] = meshgrid(x)
[X,Y,Z] = meshgrid(x,y,z)
Description
[X,Y] = meshgrid(x,y) transforms the domain specified by vectors x and y into arrays X and Y, which can be used to evaluate functions of two variables and three-dimensional mesh/surface plots. The rows of the output array X are copies of the vector x; columns of the output array Y are copies of the vector y.
[X,Y] = meshgrid(x) is the same as [X,Y] = meshgrid(x,x).
[X,Y,Z] = meshgrid(x,y,z) produces three-dimensional arrays used to evaluate functions of three variables and three-dimensional volumetric plots.

2.2  gradient
2.3 linspace

3.表达变换
hold on;
x=-2:0.05:2;
y=-2:0.05:2;
[X,Y]=meshgrid(x,y); 
Z1=1./sqrt((X-1).^2+Y.^2+0.01);
Z2=1./sqrt((X+1).^2+Y.^2+0.01);
Z=Z1+Z2;
%surf(X,Y,Z)
[dx,dy]=gradient(Z);
contour(X,Y,Z,12);
quiver(X,Y,dx,dy);
[imgid=0]

路过

雷人

握手

鲜花

鸡蛋

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-4-20 21:51 , Processed in 0.023671 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

返回顶部