Dear all
I have a task to draw a shape like star in matlab and I need someone to help me to do this and this is the shape .
Thanks

 채택된 답변

Geoff Hayes
Geoff Hayes 2015년 11월 29일

0 개 추천

Mahmoud - as this is a homework assignment, we can only give hints on how to proceed. In this case, break the star down into its components which are the five lines. How would you plot each line? You know the (x,y) coordinate for the start and the end point for each line so you can determine its slope. From that you can determine the equation for the line which you can then plot.
All lines will have the same set of points along the x-axis so we can initialize this set as
x = linspace(2,4,50);
(In the above, x will be an array of 50 elements that are linearly spaced between 2 and 4.)
Now, if we consider the horizontal line which starts at (2,4) and ends at (4,4), then the equation for this line (as an anonymous function) is
y = @(x)4;
which we can then plot as
plot(x,y(x));
You can refer to plot to see how you may adjust the plot so that it appears as a red dashed line.

댓글 수: 2

Mahmoud Mohammed
Mahmoud Mohammed 2015년 11월 29일
Thanks for quick response but you want to say that i have to find five equations for the five lines then plotting them and i will get the shape?
Geoff Hayes
Geoff Hayes 2015년 11월 29일
Yes, that is how I would go about doing this assignment. There may be alternate ways to do this, but without knowing how this relates to what you have learned in class...I am guessing that this assignment is to demonstrate the understanding behind the equation of a line (slope, intercepts, etc.)

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

추가 답변 (0개)

카테고리

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

질문:

2015년 11월 29일

댓글:

2015년 11월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by