Hi there,
can someone please tell me why my program outputs such a line?
it should look like this:
This is my code:
[u,v] = meshgrid(linspace(-2.5,2.5,40),linspace(-2.5,2.5,40));
x = u-(u.^3/3)+u.*v.^2;
y = -v+(v.^3/3)-v.*u.^2;
z = u.^2-v.^2;
mesh(x,y,z)
hold on
axis equal;
[t,X] = ode45(@Enneper,[0,4*pi],[0,.1,0,.1]);
u = X(:,1);
v = X(:,3);
x = u-(u.^3/3)+u.*v.^2;
y = -v+(v.^3/3)-v.*u.^2;
z = u.^2-v.^2;
plot3(x,y,z,'color','r','LineWidth',1);
function xprime = Enneper(t,x)
xprime = zeros(4,1);
xprime(1) = x(2);
xprime(2) = (2.*x(1).*x(4).^2)/(x(1).^2+x(3).^2+1)-(2.*x(1).*x(2).^2)/(x(1).^2+x(3).^2+1)-(4.*x(3).*x(2).*x(4))/(x(1).^2+x(3).^2+1);
xprime(3) = x(4);
xprime(4) = (2.*x(3).*x(2).^2)/(x(1).^2+x(3).^2+1)-(2.*x(3).*x(4).^2)/(x(1).^2+x(3).^2+1)-(4.*x(1).*x(2).*x(4))/(x(1).^2+x(3).^2+1);
end
Thanks!

답변 (1개)

Cris LaPierre
Cris LaPierre 2020년 11월 12일

0 개 추천

You create that line with your plot3 command. If it should be doing what is shown in your other images, you may need to check your equations for x, y, and z.

댓글 수: 9

cheb
cheb 2020년 11월 12일
Hi, thank you for your answer. The equations for x, y, z are all correct
Cris LaPierre
Cris LaPierre 2020년 11월 12일
편집: Cris LaPierre 2020년 11월 12일
Some quick googling suggests that the lines you desire are created by setting u and v equal to zero.
cheb
cheb 2020년 11월 12일
I also found and tried that, but then I get unfortunately an error message in my code
Cris LaPierre
Cris LaPierre 2020년 11월 12일
Worked for me. The image I created is in my post above.
cheb
cheb 2020년 11월 12일
really? can you maybe show me where exactly you defined that? I have only started programming a few weeks ago and probably defined it in the wrong place
Cris LaPierre
Cris LaPierre 2020년 11월 12일
I'll get you started.
  1. Find your equations for x,y and z at the bottom of your code.
  2. Change all the u's to 0.
  3. Run your code.
cheb
cheb 2020년 11월 12일
I'm trying that out now. Are the equation for x,y and z at the bottom:
, , ?
cheb
cheb 2020년 11월 12일
Sorry, i don't get it. Can you please show me, how you did that?
Cris LaPierre
Cris LaPierre 2020년 11월 12일
I suggest you reread items 1-3. I answer your questions there.

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

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

질문:

2020년 11월 12일

댓글:

2020년 11월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by