Creating of Basic Shape in Matlab

2 views (last 30 days)
Hello!
I am trying to create a rectangle as a basic shape. I use these commands:
rect=[3 4 -1 1 1 -1 -0.5 -0.5];
gd=[rect];
ns=char('rect');
sf='rect';
dl = decsg(gd,sf,ns)
But in the end I get the following error message:
Index exceeds matrix dimensions.
What is wrong with my script? I do not fully understand what the following sentences means: "3 through 6 - x-coordinate of edge starting points" and "7 through 10 - y-coordinate of edge starting points"(from MATLAB help desk). Would somebody explain me this?
I want to get a solid geometry. 'decsg' means Decompose Constructive Solid Geometry into minimal regions. I follow this example http://se.mathworks.com/help/pde/ug/create-geometry-at-the-command-line.html but cannot get a shape.
Sergey

Accepted Answer

Star Strider
Star Strider on 17 May 2015
Edited: Star Strider on 17 May 2015
I don’t have much recent experience with the PDE Toolbox, but your ‘rect’ assignment is missing the last two y-coordinates for your rectangle:
rect=[3 4 -1 1 1 -1 -0.5 -0.5 # #];
where the ‘#’ indicate the missing coordinates.
In the documentation for Create CSG Geometry at the Command Line, the ‘3 through 6’ and ‘7 through 10’ refers to the vector needing four x (in elements 3-6) and four y (in elements 7-10) coordinates to define the rectangle’s corners.
EDIT — The error, ‘Index exceeds matrix dimensions.’ means that the relevant PDE routine is looking for the last two elements in your ‘rect’ vector and can’t find them.
  2 Comments
Sergey Dukman
Sergey Dukman on 17 May 2015
Hello!
Thank you, Sir.
now it is understandable. I will try all over again.
Sergey

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!