Plotting 3d parametric equations in Matlab

In summary, the goal of this exercise is to plot parametric equations for the Agnolotti Pasta shell using the equations given in the link provided. The equations involve sine and cosine functions and the variables i and j represent the x and y coordinates, respectively. The provided code has some errors and a possible solution for plotting the equations is shown above.
  • #1
froderick
1
0

Homework Statement



The goal of this exercise is to plot parametric equations so that the image looks like the Agnolotti Pasta shell given in the link below.

http://www.nytimes.com/interactive/2012/01/10/science/20120110_pasta.html?ref=science.

Homework Equations



The relevant equations for the Agnolotti Pasta shell are given in the link

http://www.nytimes.com/interactive/2012/01/10/science/20120110_pasta.html?ref=science.

The Attempt at a Solution



I get a completely messed up image with my code below. I am not sure what I am missing to dimensionalize the figure. Any help with how to approach this problem would be greatly appreciated! I feel like I am miles away from what this looks like

i = linspace(0,60);
j = linspace(0,60);
z1 = (10.*sin(i.*pi./120).^5 + i./400.*sin(3.*j.*pi./10)).*cos(19.*j.*pi/2000 +0.03.*pi);
z2 = (10.*sin(i.*pi./120) + i./400.*sin(3.*j.*pi./10)).*cos(19.*j.*pi/2000 +0.03.*pi);
z3 = 5.*cos(i.*pi./120).^5.*sin(j.*pi./100) - 5.*sin(j.*pi./100).*cos(i.*pi./120).^200;

plot3(i,j,z1);
hold on
plot3(i,j,z2);
plot3(i,j,z3);
hold off;
 
Physics news on Phys.org
  • #2


First, it is important to clarify the goal of this exercise. Are you trying to plot parametric equations for the Agnolotti Pasta shell or are you trying to create a code that will generate an image of the pasta shell? Depending on the goal, the approach and equations used may differ.

Assuming the goal is to plot parametric equations, the first step would be to understand the equations given in the link and how they relate to the shape of the pasta shell. From the link, we can see that the shape of the pasta shell is created by three equations, each representing a different part of the shell. These equations involve sine and cosine functions, which are used to create the curves and ridges of the shell.

Next, it is important to consider the range of values for the variables in the equations. In this case, the variables i and j represent the x and y coordinates, respectively, and are given a range of 0 to 60. This means that the plot will cover a square area with a side length of 60 units.

Based on this information, the code provided in the forum post is not correct. The first issue is that the z1, z2, and z3 equations are not using the correct range for the variables. They should be using linspace(0,60) instead of linspace(0,1). Additionally, the equations used in the code are not the same as the ones given in the link.

A possible solution for plotting the parametric equations for the pasta shell could be:

i = linspace(0,60);
j = linspace(0,60);
z1 = (10.*sin(i.*pi./120).^5 + i./400.*sin(3.*j.*pi./10)).*cos(19.*j.*pi/2000 +0.03.*pi);
z2 = (10.*sin(i.*pi./120) + i./400.*sin(3.*j.*pi./10)).*cos(19.*j.*pi/2000 +0.03.*pi);
z3 = 5.*cos(i.*pi./120).^5.*sin(j.*pi./100) - 5.*sin(j.*pi./100).*cos(i.*pi./120).^2;

figure
plot3(z1,z2,z3)
xlabel('x')
ylabel('y')
zlabel('z')
title('Parametric Equations for Agnolotti Pasta Shell')

 

FAQ: Plotting 3d parametric equations in Matlab

1. What is the syntax for plotting 3D parametric equations in Matlab?

The syntax for plotting 3D parametric equations in Matlab is as follows:

plot3(x(t),y(t),z(t))

Where x(t), y(t), and z(t) represent the parametric equations in terms of the variable t.

2. How do I specify the range of t values for my parametric equations?

You can specify the range of t values by defining a vector of t values and using it as the input for the x, y, and z equations. For example, if you want to plot the equations from t = 0 to t = 10, you can use the following syntax:

t = 0:0.1:10;

plot3(x(t),y(t),z(t));

3. Can I plot multiple parametric equations on the same 3D graph?

Yes, you can plot multiple parametric equations on the same 3D graph by using the hold on command. This will allow you to plot additional equations on the same graph without overwriting the previous one. For example:

t = 0:0.1:10;

plot3(x1(t),y1(t),z1(t));

hold on;

plot3(x2(t),y2(t),z2(t));

4. How can I add labels and a title to my 3D parametric plot?

To add labels and a title to your 3D parametric plot, you can use the xlabel, ylabel, zlabel, and title commands. For example:

xlabel('x(t)');

ylabel('y(t)');

zlabel('z(t)');

title('Parametric Equations in 3D');

5. Is it possible to customize the appearance of my 3D parametric plot?

Yes, you can customize the appearance of your 3D parametric plot by using various Matlab commands such as color, line style, and marker type. For example:

plot3(x(t),y(t),z(t),'r--o');

This will plot the parametric equations in red with a dashed line and circular markers. You can also use the legend command to add a legend to your plot.

Similar threads

Replies
2
Views
1K
Replies
1
Views
1K
Replies
2
Views
1K
Replies
7
Views
990
Replies
4
Views
2K
Back
Top