Plotting a 3d curve between a given equation and x and y axis
1 view (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Image Analyst
on 19 Mar 2022
Did you try something like this? Adapt as needed:
numElements = 400;
% x varies from -4 to 4
x = linspace(-4, 4, numElements)
% y varies from -4 to 4
y = linspace(-4, 4, numElements)
% g is constant
g = 0.50
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.'))
More Answers (1)
Voss
on 19 Mar 2022
%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 Comments
Voss
on 20 Mar 2022
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);
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!