I need to create an animation that translates a plot of a square in a diagonal motion while also shrinking and lightening the color of the square. I've never used animations before and I was told to use a for loop to create the animation. However all I have completed in generating all of the squares and they are all displayed on the same figure at the same time.
figure(1)Square = [0,0,2,2;0,2,2,0];fill(Square(1,:),Square(2,:), [1 0 .7])title('Square Animation')axis equalhold onfill((Square(1,:)*.9)+2,(Square(2,:)*.9)+2.1,[1 .2 .7]) fill((Square(1,:)*.8)+3.9,(Square(2,:)*.8)+4.1,[1 .3 .7])fill((Square(1,:)*.7)+5.5,(Square(2,:)*.7)+5.8,[1 .4 .7])fill((Square(1,:)*.6)+6.9,(Square(2,:)*.6)+7.4,[1 .5 .7])fill((Square(1,:)*.5)+8.1,(Square(2,:)*.5)+8.7,[1 .6 .7])fill((Square(1,:)*.4)+9.1,(Square(2,:)*.4)+10,[1 .7 .7]) fill((Square(1,:)*.3)+10,(Square(2,:)*.3)+10.9,[1 .8 .7])fill((Square(1,:)*.2)+10.6,(Square(2,:)*.2)+11.7,[1 .9 .9])fill((Square(1,:)*.15)+11,(Square(2,:)*.15)+12.4,[1 .93 .9])fill((Square(1,:)*.1)+11.4,(Square(2,:)*.1)+13,[1 .97 .9])
Best Answer