Hi,
I tried to create an animation with PATCH but unfortunately, it only shows the final result and does not animate the whole process.
Just the values of the colorbar change.
(Picture at the bottom).
Do you have any idea that how can I create a color-changing process?
My code can be read below:
STEPS = 40;
q = zeros(14,STEPS);
q(:,1) = [0;0;0;0;0;0;0;0;0;0;0;0;0;0];
q(:,2) = [0;0;0.01;0.001;0.01;0.001;0;0;0.0025;0.00025;0.0025;0.00025;0.005;0];
for i = 3 : STEPS
q(:,i) = q(:,i-1) * 1.05;
end%for
RGB = [0 0 1
0 0.5 1
0 1 1
0 1 0.5
0 1 0
0.5 1 0
1 1 0
1 0.5 0
1 0 0];
Q = q(:,STEPS);
Q = Q(1:2:end);
% data for patch
msh_1.nn_3sz = [3,2,7;2,6,7;5,3,7;6,5,7];
msh_1.nn_4sz = [5,4,1,6];
msh_1.xy = [0,0;2,0;2,1;0,1;1,1;1,0;1.5,0.5];
figure (8)
qxy="qx";
for i = 1:STEPS
Q = q(:,i);
QX = Q(1:2:size(Q,1)-1);
QY = Q(2:2:size(Q,1));
switch qxy % displacements in X and Y dimensions
case "qx"
QQ = QX;
case "qy"
QQ = QY;
case "q"
QQ = sqrt(QX.^2+QY.^2);
end%switch
set(gcf, 'color', 'w')
colormap(RGB);
colorbar('EastOutside')
patch('Faces',msh_1.nn_3sz,'Vertices', msh_1.xy,'FaceVertexCData',QQ,'FaceColor','interp')
patch('Faces',msh_1.nn_4sz,'Vertices', msh_1.xy,'FaceVertexCData',QQ,'FaceColor','interp')
axis equal
drawnow()
end%for
The PATCH figure:
Do you have any idea how can I solve it?
Thank you so much for your helpful comments!