Clear Filters
Clear Filters

Drawing a pentagram in MATLAB

23 views (last 30 days)
Harshita Jain
Harshita Jain on 30 Apr 2016
Edited: DGM on 8 Jan 2023
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.

Answers (1)

Ismail Ken
Ismail Ken on 8 Jan 2023
Edited: Image Analyst on 8 Jan 2023
plot(fft(eye(5)*-1j),'r');
axis square
  2 Comments
John D'Errico
John D'Errico on 8 Jan 2023
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 on 8 Jan 2023
Edited: DGM on 8 Jan 2023
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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!