I am relatively new to matlab and figuring this out alone is a little above my paygrade.
I put an accelerometer on a weather balloon for a project. The accelerometer gives an X, Y, and Z component of the actual acceleration vector.
rawdata=xlsread('balloon.xlsx'); %Importing Data
time=rawdata(:,7); Zaccel=rawdata(:,2); Yaccel=rawdata(:,4); Xaccel=rawdata(:,6); resultant=rawdata(:,8); for i=1:length(resultant) %Correcting for Outliers
if resultant(i)>5 resultant(i)=0; elseif resultant(i)<1 resultant(i)=0; end end for j=1:length(Zaccel) %Correcting for Outliers if Zaccel(i)<1 Zaccel(i)=0 elseif Zaccel(i)>5 Zaccel(i)=0 elseif Yaccel(i)<1 Yaccel(i)=0 elseif Yaccel(i)>5 Yaccel(i)=0 elseif Xaccel(i)<1 Xaccel(i)=0 elseif Xaccel(i)>5 Xaccel(i)=0 end end unitx=[]; %Creating X-componant of unit vector
for i=1:length(Xaccel) unitx(i)=Xaccel(i)./resultant(i); end unity=[]; %Creating Y-componant of unit vector
for j=1:length(Yaccel) unity(j)=Yaccel(j)./resultant(j); end unitz=[]; %Creating Z-componant of unit vector
for k=1:length(Zaccel) unitz(k)=Zaccel(k)./resultant(k); end curve=animatedline('Linewidth',2); figure for i=1:length(unitx) addpoints(curve, unitx(i), unity(i), unitz(i)); drawnow end
I want to make an animation of the direction that this unit vector points through time so that each time step, the plot displays the next vector. So in essence, instead of plotting a bunch of points over time, I want each "point" to be a vector arrow pointing from the origin and I do not want them to stay plotted, I want each to be deleted as the next is plotted. I am not sure how to go about this.
Zaccel, Yaccel, and Xaccel represent the raw data given by the accelerometer. Resultant is the magnitude of the resultant vector.
Best Answer