Problems with line plots

7 Ansichten (letzte 30 Tage)
cheb
cheb am 12 Nov. 2020
Kommentiert: Cris LaPierre am 12 Nov. 2020
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!

Antworten (1)

Cris LaPierre
Cris LaPierre am 12 Nov. 2020
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 Kommentare
cheb
cheb am 12 Nov. 2020
Sorry, i don't get it. Can you please show me, how you did that?
Cris LaPierre
Cris LaPierre am 12 Nov. 2020
I suggest you reread items 1-3. I answer your questions there.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by