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 comentario

José-Luis
José-Luis el 14 de Feb. de 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.

Iniciar sesión para comentar.

Respuestas (1)

Thorsten
Thorsten el 14 de Feb. de 2013
Editada: Thorsten el 14 de Feb. de 2013
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

Categorías

Más información sobre Particle & Nuclear Physics en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 14 de Feb. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by