Write a MATLAB code that plots a shape similar to “heart”. You are required to u
ID: 3678102 • Letter: W
Question
Write a MATLAB code that plots a shape similar to “heart”. You are required to use analytical functions similar to what we have used in class. By trial and error, you can experiment with several types of functions (polynomials, trigonometric functions, logarithmic functions, exponentials, etc.) and find which ones suit you the best. There is no single right answer for this question. You can find a unique way to plot a heart which could different from the shapes above. With a similar approach, extend your code so that it also plots a “star” such as the one below. Place your heart and star plots side by side into the same figure window. Now, ask the user to enter an angle in degrees as input (0 to 360 degrees). Then use this angle to rotate the star you previously plotted. Note that you are not allowed to use built-in MATLAB functions that you have not seen in class (such as line, viscircles, etc.).
(I did the heart part, I need only the star and rotating part)
Explanation / Answer
Code for star:
theta = 0:4/5*pi:4*pi;
plot(cos(theta+pi),sin(theta+pi),'y-')
axis equal
you can the angle in bold text to any value and it will change to that angle.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.