How can i do that?
Show older comments
a. Ask the user for the length of the edge.
b. Define the axes of the chart according to the entered edge length.
c. Draw the square with the origin points (0,0) and step intervals in 0.5 units.
D. Then draw the edges in a straight line. (For example, if the user enters the number 20
You should get the image in the picture below.)
The drawing should have a star as above
how can i do that?

5 Comments
Steven Lord
on 22 Mar 2021
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the MATLAB Onramp tutorial (https://www.mathworks.com/support/learn-with-matlab-tutorials.html) to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.
Jan
on 23 Mar 2021
I see an animated image, which is such tiny, that I cannot recognize anything.
The description of the problem starts with "a. Ask the user for the length of the edge." This might be a simple |input < command, or a GUI based solution. The readers have to guess, what your problem is with this part.
I suggest to try it and to ask specific questions in the forum.
"The only thing I wanted from you was how to connect the stars in the animation part ...." - then it is not useful to post this part of the question also: "a. Ask the user for the length of the edge."
Walter Roberson
on 24 Mar 2021
"How do you know I'm not doing abc steps?"
Because you specifically told us that you discarded your previous work.
"If you can't find a solution, please don't mind, I have already done the steps you said."
I had already showed you how to draw lines and you could see the (very small) difference between that and drawing the stars. If you had in fact solved drawing the stars then the difference to drawing the line would have been literally one character, '*k' vs '-k'
"I could not get the answer I wanted"
What you appear to have wanted was a complete solution, considering that I had already shown you how to draw animated lines and stars.
Accepted Answer
More Answers (1)
Walter Roberson
on 23 Mar 2021
0 votes
You need six loop phases.
- draw the bottom stars left to right
- draw stars up on the left and right simultaneously
- draw stars on the top from left to right
- draw the line on the bottom from left to right, with shorter pause than you use for the stars
- draw the line up from the bottom on left and right simultaneously, using a shorter pause than for the stars
- draw the line across the top from left to right, using a shorter pause than for the stars
I already showed you in a previous post how to draw animated lines of stars using plot() with '*k' and drawing with different changing limits.
I already showed you in a previous post how to draw animated lines using plot with '-k' and different changing limits.
You already knew about hold on, and about pause()
I already showed you in a previous post how to change the drawing limits over time.
You already have all the tools you need to solve this.
There are some advanced techniques to make the drawing more efficient. You could look at animatedline() for example.
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!