How can I extrude a 2D curve in MATLAB along the Z direction?

  • MATLAB
  • Thread starter marellasunny
  • Start date
  • Tags
    2d Curve
In summary, the conversation discusses the process of extruding a 2D curve in the X-Y plane along the Z direction to create a plane of Z units long. It is mentioned that this can be achieved by adding a third dimension and broadcasting the same x and y values. The conversation then shifts to fitting a surface through multiple curves and using level curves to create a surface. An error is encountered when trying to use the "surf" command and it is clarified that creating a surface is not the same as creating a mesh. The conversation ends with a request for help and clarification on the use of x, y, and z coordinates in plotting 3D.
  • #1
marellasunny
255
3
Hi all!
I would like to extrude a 2d curve in the X-Y plane along the Z direction,thereby wanting to obtain a plane of Z units long.How should I proceed?
Is there a tool especially for this in MATLAB?
 
Physics news on Phys.org
  • #2
matlab or not, if all you want to do is extrude such line in a straight line, all you need to do is add the third dimension (z), add a bunch of consecutive numbers to it z=1,2,3,4... and then simply broadcast the same x,y values along the third dimension.
 
  • #3
Ok,I created it for a polynomial function(MATLAB CODE)
x=0:.1:10;
y=0:.1:10;
f=@(x)0.6.*x.^3+1.9.*x.^2+3.*x+25;
y=f(x);
z=zeros(size(x));
for i=0:.1:10
z1=z+i;
plot3(x,y,z1)
drawnow;
pause(eps);
hold on
end

Question:How do I 'fit' a surface through all these curves(assuming the curves are slightly different but parallel)?,how do I use these level curves to make a surface?"
I get an error saying"? Error using ==> surf at 78
Z must be a matrix, not a scalar or vector." when I insert the command
surf(x,y,z1)
is creating a surface the same as creating a mesh?
 
Last edited:
  • #4
first of all, I do not know matlab

second, your z1 variable is a one-dimensional vector only to which you are assigning, one at a time the values 0, 1, 2, 3, etc. Your z variable remains zero since initialized, you never assigned anything to it.

I think you first need to learn how to plot 3D, do an exercise from the user's manual and figure out what x, y, and z need to be.
 
  • #5
I am using z1 as the z coordinate,not z.
z1=z+i;
plot3(x,y,z1)
It would helpful if someone can answer the queries above.
Thank you.
 

1. What is the purpose of extruding a 2D curve in MATLAB?

The purpose of extruding a 2D curve in MATLAB is to create a three-dimensional (3D) object by extending a 2D curve along a specified direction. This allows for the creation of more complex and realistic shapes in MATLAB.

2. How do I extrude a 2D curve in MATLAB?

To extrude a 2D curve in MATLAB, you can use the "extrude" function. This function takes in the 2D curve as input and allows you to specify the extrusion direction and the length of the extruded shape. The output will be a 3D object with the specified shape and dimensions.

3. Can I extrude multiple 2D curves at once in MATLAB?

Yes, you can extrude multiple 2D curves at once in MATLAB by using the "extrude" function in a loop. This allows for the creation of more complex and intricate 3D objects by combining multiple 2D curves.

4. What types of 2D curves can be extruded in MATLAB?

Most commonly, straight lines and splines can be extruded in MATLAB. However, you can also use other types of curves such as circles, ellipses, and polygons to create 3D objects through extrusion.

5. Are there any limitations to extruding 2D curves in MATLAB?

One limitation to keep in mind when extruding 2D curves in MATLAB is that the extruded shape will always be a prism, meaning it will have a constant cross-section along the extrusion direction. Additionally, the extrusion process may not always be accurate for very complex or irregular 2D curves.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
32
Views
2K
  • General Math
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • Calculus and Beyond Homework Help
Replies
13
Views
271
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
Replies
14
Views
1K
  • Precalculus Mathematics Homework Help
Replies
17
Views
988
Back
Top