streamslice

函式簡介,程式示例,

函式簡介

函式功能:MATLAB函式streamslice用於在片層上繪製流線圖。
語法格式:
streamslice(X,Y,Z,U,V,W,startx,starty,startz)
以適中的間距繪製一族帶箭頭的流線圖。這幾個參數的含義詳見streamline函式。
streamslice(U,V,W,startx,starty,startz)
這種調用格式使用預設的X、Y、Z參數:
[m,n,p] = size(U);
[X<Y,Z] = meshgrid(1:m,1:n,1:p);
其中meshgrid函式用於生成格線數據
streamslice(X,Y,U,V)
在2-D坐標中繪製流線圖。
streamslice(U,V)
使用預設的X、Y參數。
streamslice(...,density)
streamslice(...,'arrowsmode')
streamslice(...,'method')
streamslice(axes_handle,...)
h = streamslice(...)
[vertices arrowvertices] = streamslice(...)
相關函式:streamline,meshgrid

程式示例

close all; clear; clc;
k = 8.9875e+9;
% 一個電子帶電量絕對值:
e = 1.602e-19;
e_r = 2.8e-15; % 電子的半徑
ke = k .* e; % k by e
% 指定區間: d=<x,y<=d,並生成格線數據
d = -2:0.05:2;
[x, y] = meshgrid(d);
% 計算電位
V = ke ./ sqrt(x.^2 + y.^2 + 0.01); % 加了一個0.01,防止分母為0。
% 求電勢的梯度,即電場強度
[E_x, E_y] = gradient(-V);
% 繪製電場線分布
t = 0:2*pi/20:2*pi;
sx = e_r * sin(t);
sy = e_r * cos(t);
hold on;
streamslice(x, y, E_x, E_y);
contour(x, y, V, linspace(min(V(:)), max(V(:)), 40));
hold off;

相關詞條

熱門詞條

聯絡我們