Plotting a 3d curve between a given equation and x and y axis

1 回表示 (過去 30 日間)
Amy Topaz
Amy Topaz 2022 年 3 月 19 日
コメント済み: Voss 2022 年 3 月 20 日
Need to plot a 3d curve between Hx/Hg vs x and y
Hx = (1/pi)*(arctan(((g/2 + x)/y) + arctan((g/2 - x)/y)));
%x varies from -4 to 4
%y varies from -4 to 4
%g is constant

採用された回答

Image Analyst
Image Analyst 2022 年 3 月 19 日
Did you try something like this? Adapt as needed:
numElements = 400;
% x varies from -4 to 4
x = linspace(-4, 4, numElements)
x = 1×400
-4.0000 -3.9799 -3.9599 -3.9398 -3.9198 -3.8997 -3.8797 -3.8596 -3.8396 -3.8195 -3.7995 -3.7794 -3.7594 -3.7393 -3.7193 -3.6992 -3.6792 -3.6591 -3.6391 -3.6190 -3.5990 -3.5789 -3.5589 -3.5388 -3.5188 -3.4987 -3.4787 -3.4586 -3.4386 -3.4185
% y varies from -4 to 4
y = linspace(-4, 4, numElements)
y = 1×400
-4.0000 -3.9799 -3.9599 -3.9398 -3.9198 -3.8997 -3.8797 -3.8596 -3.8396 -3.8195 -3.7995 -3.7794 -3.7594 -3.7393 -3.7193 -3.6992 -3.6792 -3.6591 -3.6391 -3.6190 -3.5990 -3.5789 -3.5589 -3.5388 -3.5188 -3.4987 -3.4787 -3.4586 -3.4386 -3.4185
% g is constant
g = 0.50
g = 0.5000
Hx = (1/pi)*(atan(((g/2 + x) ./ y) + atan((g/2 - x) ./ y)));
plot3(x, y, Hx, 'b.-', 'LineWidth', 2)
grid on
xlabel('x');
ylabel('y');
zlabel('Hx')
uiwait(helpdlg('Grab the graph and spin it around.'))
  1 件のコメント
Amy Topaz
Amy Topaz 2022 年 3 月 20 日
Thank you, could we use the surf or surface function here?

サインインしてコメントする。

その他の回答 (1 件)

Voss
Voss 2022 年 3 月 19 日
%x varies from -4 to 4
x = -4:0.1:4;
%y varies from -4 to 4
y = -4:0.1:4;
%g is constant
g = 1;
% Hx = (1/pi)*(arctan(((g/2 + x)/y) + arctan((g/2 - x)/y)));
Hx = (1/pi)*(atan(((g/2 + x)./y) + atan((g/2 - x)./y)));
plot3(x,y,Hx);
grid on
xlabel('x');
ylabel('y');
zlabel('Hx');
  3 件のコメント
Amy Topaz
Amy Topaz 2022 年 3 月 20 日
Can we not use the surface function here?
Voss
Voss 2022 年 3 月 20 日
No, we can.
%x varies from -4 to 4
x = -4:0.1:4;
%y varies from -4 to 4
y = -4:0.1:4;
%g is constant
g = 1;
[X,Y] = meshgrid(x,y);
% Hx = (1/pi)*(arctan(((g/2 + x)/y) + arctan((g/2 - x)/y)));
Hx = (1/pi)*(atan(((g/2 + X)./Y) + atan((g/2 - X)./Y)));
% surf(X,Y,Hx); surf() is another option
surface(X,Y,Hx);
view(3);

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by