Making an avi movie from a quiver plot.
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I need to make an avi file from a quiver plot. I am new to matlab so please excuse the messy code. Here it is.
rawdata=xlsread('Flight_1_fixed.xlsx'); %Importing Data
time=rawdata(:,7);
Zaccel=rawdata(:,2);
Yaccel=rawdata(:,4);
Xaccel=rawdata(:,6);
resultant=rawdata(:,1);
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
% Zaccel=-Zaccel;
% Yaccel=-Yaccel;
% Xaccel=-Xaccel;
Zaccel=-2.0833.*Zaccel+5.146;
Yaccel=1.8868.*Yaccel-4.66;
Xaccel=-1.7857.*Xaccel+4.4107;
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
for i=1:length(Xaccel)
theta(i)=atan2d(sqrt(Xaccel(i)^2+Yaccel(i)^2),-Zaccel(i));
end
fid=figure;
hold on
writerObj=VideoWriter('AccelerationVector.avi');
writerObj.FrameRate=60;
open(writerObj);
for l=1:length(unitx)
pause(1e-15);
figure(fid);
quiver3(unitx(l), unity(l), unitz(l), Xaccel(l), Yaccel(l), Zaccel(l));
view(45,45);
axis([-2 1 -2 1 -2 1]);
M(l)=getframe(gcf);
writeVideo(writerObj, M);
end
hold off
close(writerObj);
The quiver plot shows me a changing vector in the xyz-plane. All I need is to export this as an avi file to put this "movie" in a presentation, but I get errors when trying to make the movie. So I just need this in an avi file, and I am not sure what to do.
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Vector Fields dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!