2014-04-14 60 views
0

我想绘制Matlab中的电场积分E(yaxis)Vs Z(x轴)。功能如下:电场积分图

enter image description here

我想绘制的这张照片中的第一个积分E(Z)。

回答

3

有您的解析式为这个积分,你只需要设置用于Z的值,并计算相应的E(Z):

%% Set the values for z 
z = x1:0.1:x2; 
% x1 and x2 are your bounds on the X axis 
% The discrete step is set to 0.1, lower/increase it depending on the level of detail you want 

%% Compute the electric field values 
Ez = (k*l/z) .* (b/sqrt(z.*z + b*b) + a/sqrt(z.*z + a*a)); 

%% Plot the values 
plot(z, Ez); 
1

这应该不成问题。假设在绘图之前已经设置了一些常量。那是a,b,klambda。另外,由于您在MATLAB中进行绘图,您将需要不连续的步骤......所以选择一小步,如s = 0.01;。您的z值(已声明为-ab)也需要一个起点和终点。因此,代码看起来像这样:

s = 0.01; 

    % Define z values 
    z = -a : s : b; 

    % Ez values 
    E = (k*lambda/z) .* ((b/sqrt(z.^2 + b^2)) + (a/sqrt(z.^2 + a^2))); 

    plot(z, E); 
    title('E vs. Z'); 

希望这项工程!