Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Live Script with animation

MATLAB 2016a introduced Live Scripts, allowing to show plotting output next to the script. Is it somehow possible to show animations? For example, the following code in a regular script will plot a few points and then rotate the axes:

x = rand(10, 3);
plot3(x(:, 1), x(:, 2), x(:, 3), 'o')
for ii = 1:360
    camorbit(1, 10*cos(ii/90*pi)*pi/45)
    drawnow
    pause(0.01)
end

If this is embedded in a Live Script, the initial plot is shown, then seemingly nothing happens while the loop is running, then the last aspect (which is the same as the original plot) is shown in a new display item.

Alternatively, is there an option to interact with the plots in a live script (other than double-clicking to open the plot in a new figure)? E.g. rotate3d does not have an effect.

Edit: As of release 2019a, animations are possible as per release notes.

like image 918
zeeMonkeez Avatar asked Aug 30 '16 15:08

zeeMonkeez


People also ask

What is live scripting?

MATLAB® live scripts and live functions are interactive documents that combine MATLAB code with formatted text, equations, and images in a single environment called the Live Editor. In addition, live scripts store and display output alongside the code that creates it.

How do I live script MATLAB?

MATLAB converts publishing markup from the original script to formatted content in the new live script. To open an existing script ( . m ) as a live script ( . mlx ) from the Editor, right-click the document tab, and select Open scriptName as Live Script from the context menu.

How is a live script different from a regular script?

1. How is a Live Script different from a regular script? Ans:A Live Script combines regular text and MATLAB code. It allows the user to create a nicely formatted document with embedded code and the output of the code such as plots.


1 Answers

It seems the answer is no - Live Scripts are too young to be that feature rich yet. The fact alone that they're undebuggable would make me stay away from them for 1-2 versions more. Have you looked into Matlab Notebooks? If you're after pretty formatting and some basic interactivity, It might be what you seek.

like image 81
Ofek Shilon Avatar answered Oct 24 '22 09:10

Ofek Shilon