Placing circles on the ends of a vector
So I’m creating a movie model using data which describes a vector changing over time. I have the vector anchored at the origin and the head moves around according to the vector data. Because this is a bead-spring model, I want to graphically represent the beads by plotting circles at both ends of the vector. The problem I’m running into is that the bead that should be on the head of the vector is always offset by a certain amount. I can’t seem to figure out why it doesn’t have the same co-ords as the vector.
data = xlsread(‘C:UsersUserDocumentsMATLABData_Test.xlsx’,’Sheet1′);
t_s = data(:,1);
x_s = data(:,2);
y_s = data(:,3);
z_s = data(:,4);
d_s = size(t_s);
writerObj = VideoWriter(‘polymer.avi’);
open(writerObj);
for j = 1:d_s(1)
time = t_s(j);
x = x_s(j);
x1 = x*1000000;
y = y_s(j);
y1 = y*1000000;
z = z_s(j);
z1 = z*1000000;
h = quiver3(0, 0, 0, x1, y1, z1 );
set(h, ‘ShowArrowHead’, ‘off’);
axis([-5 15 -5 15 -5 15 3 5]);
title(‘it{Polymer Vibration}’,’FontSize’,16)
xlabel(‘x10^6′,’FontSize’,12);
ylabel(‘x10^6′,’FontSize’,12);
zlabel(‘x10^6′,’FontSize’,12);
timestamp_str = [‘t = ‘ num2str(time) ‘seconds’];
annotation(‘textbox’, [.05 .85 .1 .1],…
‘String’, timestamp_str);
hold all;
x2 = [0, x1];
y2 = [0, y1];
z2 = [0, z1];
scatter3( x2, y2, z2);
F(j) = getframe(gcf);
frame = getframe(gcf);
writeVideo(writerObj, frame);
clf;
disp([num2str(j) ‘ / ‘ num2str(d_s(1))])
end
movie(F);
close(writerObj);
An image of the problem I’m having:
<<http://i.imgur.com/JS1wp26.png>>So I’m creating a movie model using data which describes a vector changing over time. I have the vector anchored at the origin and the head moves around according to the vector data. Because this is a bead-spring model, I want to graphically represent the beads by plotting circles at both ends of the vector. The problem I’m running into is that the bead that should be on the head of the vector is always offset by a certain amount. I can’t seem to figure out why it doesn’t have the same co-ords as the vector.
data = xlsread(‘C:UsersUserDocumentsMATLABData_Test.xlsx’,’Sheet1′);
t_s = data(:,1);
x_s = data(:,2);
y_s = data(:,3);
z_s = data(:,4);
d_s = size(t_s);
writerObj = VideoWriter(‘polymer.avi’);
open(writerObj);
for j = 1:d_s(1)
time = t_s(j);
x = x_s(j);
x1 = x*1000000;
y = y_s(j);
y1 = y*1000000;
z = z_s(j);
z1 = z*1000000;
h = quiver3(0, 0, 0, x1, y1, z1 );
set(h, ‘ShowArrowHead’, ‘off’);
axis([-5 15 -5 15 -5 15 3 5]);
title(‘it{Polymer Vibration}’,’FontSize’,16)
xlabel(‘x10^6′,’FontSize’,12);
ylabel(‘x10^6′,’FontSize’,12);
zlabel(‘x10^6′,’FontSize’,12);
timestamp_str = [‘t = ‘ num2str(time) ‘seconds’];
annotation(‘textbox’, [.05 .85 .1 .1],…
‘String’, timestamp_str);
hold all;
x2 = [0, x1];
y2 = [0, y1];
z2 = [0, z1];
scatter3( x2, y2, z2);
F(j) = getframe(gcf);
frame = getframe(gcf);
writeVideo(writerObj, frame);
clf;
disp([num2str(j) ‘ / ‘ num2str(d_s(1))])
end
movie(F);
close(writerObj);
An image of the problem I’m having:
<<http://i.imgur.com/JS1wp26.png>> So I’m creating a movie model using data which describes a vector changing over time. I have the vector anchored at the origin and the head moves around according to the vector data. Because this is a bead-spring model, I want to graphically represent the beads by plotting circles at both ends of the vector. The problem I’m running into is that the bead that should be on the head of the vector is always offset by a certain amount. I can’t seem to figure out why it doesn’t have the same co-ords as the vector.
data = xlsread(‘C:UsersUserDocumentsMATLABData_Test.xlsx’,’Sheet1′);
t_s = data(:,1);
x_s = data(:,2);
y_s = data(:,3);
z_s = data(:,4);
d_s = size(t_s);
writerObj = VideoWriter(‘polymer.avi’);
open(writerObj);
for j = 1:d_s(1)
time = t_s(j);
x = x_s(j);
x1 = x*1000000;
y = y_s(j);
y1 = y*1000000;
z = z_s(j);
z1 = z*1000000;
h = quiver3(0, 0, 0, x1, y1, z1 );
set(h, ‘ShowArrowHead’, ‘off’);
axis([-5 15 -5 15 -5 15 3 5]);
title(‘it{Polymer Vibration}’,’FontSize’,16)
xlabel(‘x10^6′,’FontSize’,12);
ylabel(‘x10^6′,’FontSize’,12);
zlabel(‘x10^6′,’FontSize’,12);
timestamp_str = [‘t = ‘ num2str(time) ‘seconds’];
annotation(‘textbox’, [.05 .85 .1 .1],…
‘String’, timestamp_str);
hold all;
x2 = [0, x1];
y2 = [0, y1];
z2 = [0, z1];
scatter3( x2, y2, z2);
F(j) = getframe(gcf);
frame = getframe(gcf);
writeVideo(writerObj, frame);
clf;
disp([num2str(j) ‘ / ‘ num2str(d_s(1))])
end
movie(F);
close(writerObj);
An image of the problem I’m having:
<<http://i.imgur.com/JS1wp26.png>> plot quiver scatter MATLAB Answers — New Questions