Drawing a pentagram in MATLAB

조회 수: 19 (최근 30일)
Harshita Jain
Harshita Jain 2016년 4월 30일
편집: DGM 2023년 1월 8일
Write a program that draw a pentagram of user-­‐specified size. Specifications: 1) The pentagram is of user-­‐specified size. Note the five tips of the pentagram are located on a circle? Your program will prompt the user for the radius of that circle; your program should validate for positive numbers. 2) Use geometry/trigonometry to calculate the x vector and y vector of the tips that are necessary to plot he pentagram. 3) Do not use loops. Instead, use arrays and array math.

답변 (1개)

Ismail Ken
Ismail Ken 2023년 1월 8일
편집: Image Analyst 2023년 1월 8일
plot(fft(eye(5)*-1j),'r');
axis square
  댓글 수: 2
John D'Errico
John D'Errico 2023년 1월 8일
Please do not do obvious homework assignments for students. This does not help the student. It teaches them only that they can hope to find someone willing to do the work assigned to them as a student. It hurts the site, because it teaches that student to ask agin, posting all of their homework questions with no effort made. It hurts the site, because now all students will come to believe they too can post their homework here with no effort made.
DGM
DGM 2023년 1월 8일
편집: DGM 2023년 1월 8일
I think this example is fair enough, as it does not directly meet the requirements of the assignment, and I think it's clear that the assignment doesn't intend this approach. It's also an 8-year old question, so OP's needs part of the equation anymore. Any new students who are struggling with trig and vectorized operations are probably going to have more trouble unpacking this example than they would solving the problem in the intended manner. Maybe some of them will give it a thought, and that's a good thing.

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

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by