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

José-Luis
José-Luis 2013년 2월 14일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Thorsten
Thorsten 2013년 2월 14일
편집: Thorsten 2013년 2월 14일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기

태그

질문:

2013년 2월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by