what i have so far
r = linspace(0,2*pi);
th = 0:pi/6:2*pi ;
[R,T] = meshgrid(r,th) ;
X = R.*cos(T) ;
Y = R.*sin(T) ;
Z = R ;
surf(X,Y,Z)
What i'm wondering is, how do i make the length of each side of the base a user input,
and how do i make the height of the decagonal pyramid a user input as well.

댓글 수: 1

Dyuman Joshi
Dyuman Joshi 2023년 10월 22일
Use input
Though, with the given method of generating the pyramid, the lenght of each side of the base is the same.

댓글을 달려면 로그인하십시오.

 채택된 답변

Matt J
Matt J 2023년 10월 22일
편집: Matt J 2023년 10월 22일

0 개 추천

sidelength=10; height=8; %User inputs
V=nsidedpoly(10,'Side',sidelength).Vertices;
V(end+1,3)=-height;
trisurf( delaunay(V(:,1:2)), V(:,1), V(:,2), V(:,3),'FaceColor','c')

댓글 수: 3

Matthew
Matthew 2023년 10월 22일
편집: Matthew 2023년 10월 22일
This is perfect, thank you.
I'm trying to create a user input program that creates a new shape that fits inside the decagon at the intersection of two sides. i added some code to create that angle in degrees based off the input.
sidelength = input('Enter Sidelength');
height = input('Enter Height');
V=nsidedpoly(10,'Side',sidelength).Vertices;
V(end+1,3)=-height;
trisurf( delaunay(V(:,1:2)), V(:,1), V(:,2), V(:,3),'FaceColor','c')
%% calculating angle for new shape based off sidelength and height input
x6 = (sidelength*3.078)/2
angle1 = atand(height/x6)
angle2 = 90-angle1
My question now is how do i plot a new (almost like an obtuse V) shape that would fit inside the decagon at the intersection of both these angles? the new shape doesn't need to run the length of both sides, and doesn't need to be very wide either.
I know this is alot, and i'm sorry if my question is enigmatic
Matt J
Matt J 2023년 10월 22일
There's nothing wrong with asking more questions, but please Accept-click the answer to this question and post your new one in a new thread.
Matthew
Matthew 2023년 10월 22일
ok will do, thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Line Plots에 대해 자세히 알아보기

질문:

2023년 10월 22일

댓글:

2023년 10월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by