MATLAB Spirograph Animations with Grid Lines

In summary, The person is having a problem using comet and grid lines in their spirograph program in MATLAB. Whenever they use the grid command, the entire graph disappears. They have found a solution by using the hold on command and running the program twice, but are looking for suggestions on how to avoid this. They are advised to use the 'hold on' and 'hold off' commands, but there are also more advanced options available using the set() and get() commands.
  • #1
abercrombiems02
114
0
I have a small technical problem in MATLAB. I am trying to use comet to make an animated path of this spirograph program I've made. I'd also like to add some grid lines however my problem is the following. If i run the comet command everything looks great and works fine, but if I then use a "grid" or "grid on" command, my whole graph disappears. If I try either of the grid commands frist, they are instantly removed when the comet line runs. The only solution I have is to use the hold on command and run the program twice? Any suggestions?
 
Physics news on Phys.org
  • #2
there' is a figure command to say hold so that you draw onto the previous graph...but you shouldn't have to run it twice. It should draw overlap.
 
  • #3
neurocomp2003 said:
there' is a figure command to say hold so that you draw onto the previous graph...but you shouldn't have to run it twice. It should draw overlap.

type "help hold on" or "help hold".
 
  • #4
If you want to get even more technical (don't bother unless you want to do anything fancy), you can check out the set() and get() commands to learn how to adjust axis variables and settings.

For simple things, 'hold on' and 'hold off' should work fine.
 

1. How do I create a spirograph animation in MATLAB?

To create a spirograph animation in MATLAB, you can use the "animatedline" function to plot the points of the spirograph as it moves. You can also use the "hold on" and "hold off" commands to add multiple plots to the animation. Additionally, you can use the "pause" function to control the speed of the animation.

2. Can I add grid lines to my MATLAB spirograph animation?

Yes, you can add grid lines to your MATLAB spirograph animation by using the "grid on" command. This will add a grid to the current axes of your plot. You can also customize the grid lines by changing the color, style, and spacing.

3. How can I save my MATLAB spirograph animation as a video?

To save your MATLAB spirograph animation as a video, you can use the "VideoWriter" function. This will create a video object that you can write frames to. You can then use the "open" and "writeVideo" functions to save each frame of your animation as an image and add it to the video object. Finally, you can use the "close" function to save the video file.

4. Is it possible to animate multiple spirographs at once in MATLAB?

Yes, it is possible to animate multiple spirographs at once in MATLAB. You can use the "for" loop to create and animate multiple spirographs with different parameters. You can also use the "subplot" function to display multiple spirographs side by side in one plot.

5. Can I change the color and size of the spirograph in my MATLAB animation?

Yes, you can change the color and size of the spirograph in your MATLAB animation. You can use the "plot" function to specify the color and size of the spirograph by adding additional arguments. For example, you can use "plot(x,y,'r','LineWidth',2)" to plot a red spirograph with a line width of 2 points.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
944
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
5K
  • Programming and Computer Science
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top