Wednesday, April 24, 2024
HomeMatlabWhat’s New in MATLAB R2022a? – Nick Higham

What’s New in MATLAB R2022a? – Nick Higham


The append possibility of the exportgraphics operate now helps the GIF format, enabling one to create animated GIFs (beforehand solely multipage PDF information had been supported). The important thing command is exportgraphics(gca,file_name,"Append",true). There are different methods of making animated GIFs in MATLAB, however this one is especially straightforward. Right here is an instance M-file (primarily based on cheb3plot in MATLAB Information) with its output beneath.

%CHEB_GIF  Animated GIF of Chebyshev polynomials.
%   Based mostly on cheb3plot in MATLAB Information.
x = linspace(-1,1,1500)';
p = 49
Y = ones(size(x),p);

Y(:,2) = x;
for ok = 3:p
  Y(:,ok) = 2*x.*Y(:,k-1) - Y(:,k-2);
finish

delete cheby_animated.gif
a = get(groot,'defaultAxesColorOrder'); m = size(a);

for j = 1:p-1 % size(ok)
    plot(x,Y(:,j),'LineWidth',1.5,'shade',a(1+mod(j-1,m),:));
    xlim([-1 1]), ylim([-1 1])  % Should freeze axes.
    title(sprintf('%2.0f', j),'FontWeight','regular')
    exportgraphics(gca,"cheby_animated.gif","Append",true)
finish

cheby_animated.gif

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments