help! my variable entry is not displaying as entered.
Afficher commentaires plus anciens
%loop that will have 2000 iterations (each iteration
%representing a rotation of the plane by 0.5 degrees)
for t= 1:2000
Output=zeros(1,2000);
format('long')
%imagine points in 2-dimensional euclidean space. These three vectors
%represent the three vertices of an equilateral triangle cetered at the
%origin
A = [-0.5; 0.5];
B = [-0.5; -0.5];
C = [0.5; -0.5];
D = [0.5; 0.5];
%T is designed to be a 0.5 degree counter-clockwise rotation matrix, sending each of the
%previous vectors to their 0.5 degree rotated counterparts
T= [ 0.99996 -0.00873;0.00873 0.99996];
%represent the rotated images of A,B,C, for some iteration 't'
tA=(T^t)*A;
tB=(T^t)*B;
tC=(T^t)*C;
tD=(T^t)*D;
%tE=(T^t)*E
%tF=(T^t)*F
%tG=(T^t)*G
%tH=(T^t)*H
%tI=(T^t)*I
%P extracts the x values of each vector above, discarding the rest
P= [1 0];
%represent the projection of tA,tB,tC onto the x-axis.
imA=P*tA;
imB=P*tB;
imC=P*tC;
imD=P*tD;
%imE=P*tE;
%imF=P*tF;
%imG=P*tG;
%imH=P*tH;
%imI=P*tI;
%imJ=P*tJ;
%distances between the respective projections
distAB=abs(imA-imB);
distBC=abs(imB-imC);
distCD=abs(imC-imD);
distDA=abs(imD-imA);
distAC=abs(imC-imA);
distBD=abs(imB-imD);
%making a vector V with elements 'distAB' 'distBC' 'distCA'
X1=[1 0 0 0 0 0];
X2=[0 1 0 0 0 0];
X3=[0 0 1 0 0 0];
X4=[0 0 0 1 0 0];
X5=[0 0 0 0 1 0];
X6=[0 0 0 0 0 1];
dX1=distAB.*X1;
dX2=distBC.*X2;
dX3=distCD.*X3;
dX4=distDA.*X4;
dX5=distAC.*X5;
dX6=distBD.*X6;
V= dX1+dX2+dX3+dX4+dX5+dX6;
% D = max element in V is the width of the 'shadow' of the triangle on the
%x-axis
D=max(V);
Output(t)=D;
end
When I run the script, my vector 'D', which, as far as I can tell is very clearly defined as a 2x1 vector, is assigned the value '1.1597'.. seemingly without my consent or permission!
Can anyone figure out where this anomalous value is coming from?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Image Arithmetic dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!