Plotting of a function of 3 variables

Hello everybody
I'm trying to plot a graph of potential,V VS x,y,z coordinates.
Does anyone know how to do this?
I have tried surf and isosurface but does not work.
clear;
G=6.67;
m1=5;
m2=2;
mu=m2/(m1+m2);
omega=0.5;
a=10;
x=[0:1:100];
y=[0:1:100];
z=[0:1:100];
for i=1:length(x)
for j=1:length(y)
for k=1:length(z)
V(i,j,k)=(-G*m1/(sqrt(x(i)^2+y(j)^2+z(k)^2)))+(-G*m2/(sqrt((x(i)-a)^2+y(j)^2+z(k)^2)))-0.5*(omega^2)*(x(i)-mu*a)^2+y(j)^2;
end
end
end

1 Kommentar

José-Luis
José-Luis am 14 Feb. 2013
You are trying to plot 4-dimensional data. Surf and isosurface are not going to work. What you could do is use scatter3 and color code you plot.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Thorsten
Thorsten am 14 Feb. 2013
Bearbeitet: Thorsten am 14 Feb. 2013

0 Stimmen

One way is to look at 3 cross-sections along the main axis
for i = 1:50:100
mesh(V(:, :, i), 'EdgeColor', 'k')
if i == 1, hold on, end
zlabel('z', 'Color', 'k', 'FontWeight', 'bold', 'Rotation', pi/2)
end
for i = 1:50:100
mesh(shiftdim(V(:, i, :), 2), 'EdgeColor', 'r')
ylabel('y', 'Color', 'r', 'FontWeight', 'bold')
end
for i = 1:50:100
mesh(shiftdim(V(i, :, :), 1), 'EdgeColor', 'b')
xlabel('x', 'Color', 'b', 'FontWeight', 'bold')
end

Kategorien

Mehr zu Particle & Nuclear Physics finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by