How to make animation in MATLAB GUI...?

17 views (last 30 days)
Rupesh Gosavi
Rupesh Gosavi on 5 Jun 2014
Commented: yeungor on 6 Nov 2017
I want to make animation of diagram or say real time change in diagram with respect to results I get. I also want to know the real time plot of graph. Please guide me with examples or videos.

Answers (1)

Image Analyst
Image Analyst on 5 Jun 2014
That's the same thing my teenage son asked last night. What we did was to create a for loop, plot our functions inside the loop, then put in a pause of 0.1 seconds pause(0.1). The loop changed some parameter of the plot with each iteration and when the program ran, it gave the appearance of the lines on the plot changing and moving. For what it's worth, here is his code
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 13;
for p=0:100
p
for x=-20:50
y(x+21)=(x-2)^2-3;
y2(x+21)=2*x^3-4*x^2+3*x+15;
y3(x+21)=3*x^2+5*x+130*sin(x+p);
end
y4=-y3
plot(y,'bo-','linewidth',3,'markersize',5)
hold on
plot(y2,'rp-','linewidth',3,'markersize',5)
plot(y3,'kd-','linewidth',3,'markersize',5)
plot(y4,'kd-','linewidth',3,'markersize',5)
grid on
if p==0
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
end
ylim([-1000,1400])
caption=sprintf('%d',p);
title(caption,'fontsize',25);
legend('y1','y2','y3','y4')
drawnow
pause(0.1)
hold off
end
Not too bad for someone who just finished 10th grade.
  4 Comments
yeungor
yeungor on 6 Nov 2017
@Mosen, you're picking on a 10th grader. You could at least give constructive criticism, but it's probably pointless, I'm pretty sure Image Analyst could give his son better advice any day of the week.

Sign in to comment.

Categories

Find more on App Building 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!