Drawing a pentagram in MATLAB

38 次查看(过去 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