How will I write a code for a stack of diamond in matlab?

3 visualizaciones (últimos 30 días)
Adamu Mohammed
Adamu Mohammed el 13 de Jul. de 2020
Respondida: Image Analyst el 18 de Jul. de 2020
I want to write a code for a geometry wich look like a stack of diamonds. First in 2D (exactly as shown below) and secondly in 3D (cylindrical) which will look like a folded 2D geometry.
Thank you.

Respuestas (1)

Image Analyst
Image Analyst el 18 de Jul. de 2020
Make just one square with 4 coordinates. Then put into a loop where you add the required x and y offset to the set of 4 coordinates. Here's a start:
x4 = [1, 2, 1, 0, 1]
y4 = [0, 1, 2, 1, 0]
plot(x4, y4, 'b-', 'LineWidth', 2);
axis equal
xOffsets = [0, 4, 4, 6, 1, 3, 5, ............] % For you to figure out.
yOffsets = [0, 0, 0, 0, 2, 2, 2, .......]
for k = 1 : length(xOffsets)
x = x4 + xOffsets(k);
y = y4 + yOffsets(k);
plot(x, y, 'b-');
hold on;
end
grid on;
Let us know if you can't figure out the last few characters.

Categorías

Más información sobre 3-D Scene Control en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by