# Can someone help me with these 3D plots?

4 visualizzazioni (ultimi 30 giorni)
Victor il 16 Dic 2013
Modificato: sixwwwwww il 16 Dic 2013
/matlabcentral/answers/uploaded_files/5868/final%20project.png Can anyone help me with the last 3 plots? you can see the paramters in the link
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

sixwwwwww il 16 Dic 2013
Modificato: sixwwwwww il 16 Dic 2013
you can plot these shapes in the following two ways(you can choose better way you like):
%%Seashell
[u, v] = meshgrid(linspace(0, 6 * pi, 100), linspace(0, 2 * pi, 100));
x = 2 * (1 - exp(u / (6 * pi))) .* cos(u) .* (cos(0.5 * v))^2;
y = 2 * (-1 + exp(u / (6 * pi))) .* sin(u) .* (cos(0.5 * v))^2;
z = 1 - exp(u / (3 * pi)) - sin(v) + exp(u / (6 * pi)) .* sin(v);
figure, surf(x, y, z), xlabel('x'), ylabel('y'), zlabel('z'), title('Seashell')
%%Eight torus
c = 1;
[u, v] = meshgrid(linspace(-pi, pi, 100));
x = cos(u) .* (c + sin(v) .* cos(u) - sin(2 * v) .* (sin(u) / 2));
y = sin(u) .* (c + sin(v) .* cos(u) - sin(2 * v) .* (sin(u) / 2));
z = sin(u) .* sin(v) + cos(u) .* (sin(2 * v) / 2);
figure, surf(x, y, z), xlabel('x'), ylabel('y'), zlabel('z'), title('Eight torus')
%%Helical spring
r1 = 0.25;
r2 = 0.25;
T = 2;
n = 6;
[u, v] = meshgrid(linspace(0, 2 * n * pi, 100), linspace(0, 2 * pi, 100));
x = (1 - r1 * cos(v)) .* cos(u);
y = (1 - r1 * cos(v)) .* sin(u);
z = r2 * (sin(v) + T * u / pi);
figure, surf(x, y, z), xlabel('x'), ylabel('y'), zlabel('z'), title('Helical spring')
%%Cornucopia
a = 0.3;
b = 0.5;
[u, v] = meshgrid(linspace(0, 2 * pi, 100), linspace(-3, 3, 100));
x = exp(b * v) .* cos(v) + exp(a * v) .* cos(u) .* cos(v);
y = exp(b * v) .* sin(v) + exp(a * v) .* cos(u) .* sin(v);
z = exp(a * v) .* sin(u);
figure, surf(x, y, z), xlabel('x'), ylabel('y'), zlabel('z'), title('Cornucopia')
Or alternatively you can also plot them using ezsurf as follows:
syms u v
%%Seashell
x = 2 * (1 - exp(u / (6 * pi))) * cos(u) * (cos(0.5 * v))^2;
y = 2 * (-1 + exp(u / (6 * pi))) * sin(u) * (cos(0.5 * v))^2;
z = 1 - exp(u / (3 * pi)) - sin(v) + exp(u / (6 * pi)) * sin(v);
figure, ezsurf(x, y, z)
%%Eight torus
c = 1;
x = cos(u) * (c + sin(v) * cos(u) - sin(2 * v) * (sin(u) / 2));
y = sin(u) * (c + sin(v) * cos(u) - sin(2 * v) * (sin(u) / 2));
z = sin(u) * sin(v) + cos(u) * (sin(2 * v) / 2);
figure, ezsurf(x, y, z)
%%Helical spring
r1 = 0.25;
r2 = 0.25;
T = 2;
n = 6;
x = (1 - r1 * cos(v)) .* cos(u);
y = (1 - r1 * cos(v)) .* sin(u);
z = r2 * (sin(v) + T * u / pi);
figure, ezsurf(x, y, z)
%%Cornucopia
a = 0.3;
b =0.5;
x = exp(b * v) .* cos(v) + exp(a * v) .* cos(u) .* cos(v);
y = exp(b * v) .* sin(v) + exp(a * v) .* cos(u) .* sin(v);
z = exp(a * v) .* sin(u);
figure, ezsurf(x, y, z)
I hope it helps. Good luck!
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Mathematics in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by