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

  • Context: MATLAB 
  • Thread starter Thread starter marellasunny
  • Start date Start date
  • Tags Tags
    2d Curve
Click For Summary

Discussion Overview

The discussion revolves around the process of extruding a 2D curve in MATLAB along the Z direction to create a surface. Participants explore methods for achieving this extrusion and address issues related to plotting and surface creation in a 3D space.

Discussion Character

  • Technical explanation
  • Homework-related
  • Debate/contested

Main Points Raised

  • One participant seeks guidance on how to extrude a 2D curve in MATLAB and whether there is a specific tool for this purpose.
  • Another participant suggests a straightforward method of adding a third dimension by creating a series of Z values and broadcasting the X and Y values accordingly.
  • A participant shares MATLAB code for creating a polynomial function and asks how to fit a surface through the generated curves, expressing confusion over an error encountered when using the surf command.
  • One participant critiques the approach of using a one-dimensional vector for Z values, suggesting that the user needs to understand the requirements for plotting in 3D.
  • The original poster clarifies that they are using a different variable for Z coordinates and requests further assistance with their queries.

Areas of Agreement / Disagreement

Participants express differing levels of familiarity with MATLAB, and there is no consensus on the best approach to extrude the curve or resolve the plotting issues. The discussion remains unresolved regarding the specific method to fit a surface through the curves.

Contextual Notes

There are limitations in the understanding of how to properly structure the Z data for surface plotting, and the discussion highlights the need for clarity on the dimensional requirements for 3D plotting in MATLAB.

marellasunny
Messages
245
Reaction score
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
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.
 
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:
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.
 
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.
 

Similar threads

Replies
5
Views
3K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
15K