I read some related discussion:
How to add dynamic data labels inside of .avi animation?
These examples are much difficult than mine so I cannot quite understand how to solve my problem.
I made the following animation, I just want to
- add the label "{E}" under the "center blue point"
- add the label "{P}" near the "small blue circle", which rotate the "center blue point" and inside the "middle blue circle".
- add the label "{S}" near the "small red *", which rotate the "big blue circle".
Of course labels {P} and {S} should closely follow each corresponding object.
How could I do that? ...
clear all;
close all;
clc
%% time specifications
stoptime = 8;
fs = 50;
dt = 1/fs;
t = (0:dt:stoptime)';
N = size(t,1);
%%
vx(:,1) = 0;vy(:,1) = 15;vz(:,1) = 0;
ux(:,1) = 0 ;uy(:,1) = 3 ;uz(:,1) = 0;
%% angular velocity
Ix = 3,5;
Iz = 1;
w = .1; % w_L
wp = ( (Ix-Iz)/Iz )*w*(2)^.5
%%
for k = 2:N
vx(:,k) = cos(w*(k-1))*vx(:,1) - sin(w*(k-1))*vy(:,1) + 0*vz(:,1);
vy(:,k) = sin(w*(k-1))*vx(:,1) + cos(w*(k-1))*vy(:,1) + 0*vz(:,1);
vz(:,k) = 0*vx(:,k-1) + 0*vy(:,k-1) + 1*vz(:,k-1);
ux(:,k) = cos((w+wp)*(k-1))*ux(:,1) - sin((w+wp)*(k-1))*uy(:,1) + 0*uz(:,1) + vx(:,k);
uy(:,k) = sin((w+wp)*(k-1))*ux(:,1) + cos((w+wp)*(k-1))*uy(:,1) + 0*uz(:,1) + vy(:,k);
uz(:,k) = 0*ux(:,1) + 0*uy(:,1) + 1*uz(:,1) + vz(:,k);
o = [0;0];
xline = [vx(:,k);o(1,1)];
yline = [vy(:,k);o(2,1)];
xline1 = [vx(:,k);ux(:,k)];
yline1 = [vy(:,k);uy(:,k)];
figure(1)
ang=0:0.01:2*pi;
xp=15*cos(ang);
yp=15*sin(ang);
xp1=3*cos(ang)+vx(:,k);
yp1=3*sin(ang)+vy(:,k);
plot(xp,yp,'c--'); hold on
plot(xp1,yp1); hold on
plot(0,0,'.'); hold on
plot(xline,yline); hold on
plot(xline1,yline1); hold on
plot(vx(:,k),vy(:,k),'bo');
plot(ux(:,k),uy(:,k),'r*'); hold on
axis([-25 25 -25 25]);
axis equal
axis manual
pause(.1);
hold off
end
Sorry, I have no idea to upload my animation video. That is just the picture of it.