Rotating a Point in XY Plane
The rotation process is done through multiplying the point coordiantes with the rotation matrix.
clc
clear
theta=(90*pi)/180;
a(1,1)=cos(theta)
a(1,2)=sin(theta)
a(2,1)=-sin(theta)
a(2,2)=cos(theta)
x=[ 1 2]
xx=x*a
clear
theta=(90*pi)/180;
a(1,1)=cos(theta)
a(1,2)=sin(theta)
a(2,1)=-sin(theta)
a(2,2)=cos(theta)
x=[ 1 2]
xx=x*a
Example
clc
clear
x=[1:0.2:2.2];
y=[ 2.7183 3.3201 4.0552 4.9530 6.0496 7.3891 9.0250 ];
N=size(x);
M=size(y);
NN=max(N);
MM=max(M);
j=0;
for i=1:MM-1;
j=j+1;
y1(j)=y(i+1)-y(i);
%pause
%y1
end
MMM=size(y1);
MMMM=max(MMM)
j=0;
for i=1:MMMM-1;
j=j+1;
y2(j)=y1(i+1)-y1(i);
%pause
%y2
end
MMMMM=size(y2);
MMMMMM=max(MMMMM)
j=0;
for i=1:MMMMMM-1;
j=j+1;
y3(j)=y2(i+1)-y2(i);
%pause
%y3
end
b=size(y3);
bb=max(b)
j=0;
for i=1:bb-1;
j=j+1;
y4(j)=y3(i+1)-y3(i);
%pause
%y4
end
bbb=size(y4);
bbbb=max(bbb)
j=0;
for i=1:bbbb-1;
j=j+1;
y5(j)=y4(i+1)-y4(i);
%pause
%y5
end
c=size(y5);
f=size(y5);
ff=max(f)
j=0;
for i=1:ff-1;
j=j+1;
y6(j)=y5(i+1)-y5(i);
%pause
%y6
end
f=size(y6);
ff=max(f)
u1= [ y(1) y1(1) y2(1) y3(1) y4(1) y5(1) y6(1) ]
u2= [ y(2) y1(2) y2(2) y3(2) y4(2) y5(2) ]
u3= [ y(3) y1(3) y2(3) y3(3) y4(3)]
u4= [ y(4) y1(4) y2(4) y3(4)]
u5= [ y(5) y1(5) y2(5)]
u6= [ y(6) y1(6) ]
u7= [ y(7) ]
y'
y1'
y2'
y3'
y4'
y5'
y6'
h=0.2;
dydx=(1/h)*(y1(2)-0.5*y2(2)+(1/3)*y3(2)-0.25* y4(2)+(1/5)*y5(2))
clear
x=[1:0.2:2.2];
y=[ 2.7183 3.3201 4.0552 4.9530 6.0496 7.3891 9.0250 ];
N=size(x);
M=size(y);
NN=max(N);
MM=max(M);
j=0;
for i=1:MM-1;
j=j+1;
y1(j)=y(i+1)-y(i);
%pause
%y1
end
MMM=size(y1);
MMMM=max(MMM)
j=0;
for i=1:MMMM-1;
j=j+1;
y2(j)=y1(i+1)-y1(i);
%pause
%y2
end
MMMMM=size(y2);
MMMMMM=max(MMMMM)
j=0;
for i=1:MMMMMM-1;
j=j+1;
y3(j)=y2(i+1)-y2(i);
%pause
%y3
end
b=size(y3);
bb=max(b)
j=0;
for i=1:bb-1;
j=j+1;
y4(j)=y3(i+1)-y3(i);
%pause
%y4
end
bbb=size(y4);
bbbb=max(bbb)
j=0;
for i=1:bbbb-1;
j=j+1;
y5(j)=y4(i+1)-y4(i);
%pause
%y5
end
c=size(y5);
f=size(y5);
ff=max(f)
j=0;
for i=1:ff-1;
j=j+1;
y6(j)=y5(i+1)-y5(i);
%pause
%y6
end
f=size(y6);
ff=max(f)
u1= [ y(1) y1(1) y2(1) y3(1) y4(1) y5(1) y6(1) ]
u2= [ y(2) y1(2) y2(2) y3(2) y4(2) y5(2) ]
u3= [ y(3) y1(3) y2(3) y3(3) y4(3)]
u4= [ y(4) y1(4) y2(4) y3(4)]
u5= [ y(5) y1(5) y2(5)]
u6= [ y(6) y1(6) ]
u7= [ y(7) ]
y'
y1'
y2'
y3'
y4'
y5'
y6'
h=0.2;
dydx=(1/h)*(y1(2)-0.5*y2(2)+(1/3)*y3(2)-0.25* y4(2)+(1/5)*y5(2))
Example
clc
clear
M=10;
N=10;
a=0;
t=1;
for i=1:M;
a=a+1;
x(i,t)=randn(1,1);
end b=0;
t=1;
for j=1:N;
b=b+1;
y(j,t)=randn(1,1);
end L=M+N;
c=0;
d=0;
dd=0;
t=1;
k=1:L;
c=c+1;
if (c<=M);
d=d+1;
z(c,t)=x(d);
elseif (c>=N)
dd=dd+1;
z(c,t)=y(dd);
end
end
x'
y'
z'
Example
clc
clear
M=1;
N=5;
%One Dimensional Matrix
for i=1:M;
for j=1:N;
x(i,j)=randn(1,1);
end
end
%One Dimensional Matrix Transpose
for i=1:M;
for j=1:N;
xt(j,i)=x(i,j);
end
end
clear
M=1;
N=5;
%One Dimensional Matrix
for i=1:M;
for j=1:N;
x(i,j)=randn(1,1);
end
end
%One Dimensional Matrix Transpose
for i=1:M;
for j=1:N;
xt(j,i)=x(i,j);
end
end
Example
clc
clear
M=1;
N=5;
%One Dimensional Matrix
for i=1:M;
for j=1:N;
x(i,j)=randn(1,1);
end
end
%One Dimensional Matrix Transpose
for i=1:M;
for j=1:N;
xt(j,i)=x(i,j);
end
end
%Checking Output
x
xt
for i=1:M;
for j=1:N;
xxxt(j,i)=x(i,j)*xt(j,i);
end
end
xxt=sum(xxxt) x*xt
clear
M=1;
N=5;
%One Dimensional Matrix
for i=1:M;
for j=1:N;
x(i,j)=randn(1,1);
end
end
%One Dimensional Matrix Transpose
for i=1:M;
for j=1:N;
xt(j,i)=x(i,j);
end
end
%Checking Output
x
xt
for i=1:M;
for j=1:N;
xxxt(j,i)=x(i,j)*xt(j,i);
end
end
xxt=sum(xxxt) x*xt
Matrix Used for a 3D Space, Function of Time and Used for three Scalars
clc
clear
L=30;
M=30;
N=30;
time=10;
for s=1:3;
for t=1:time;
for i=1:L;
for j=1:M;
for k=1:N;
Q(i,j,k,t,s)=randn(1,1);
end
end
end
end
end
figure('Position',[10 10 1700 900])
contour(Q(:,:,1,3,2),12)
xlabel('x axis')
ylabel('y axis')
title('Plotting the Right Hand Side')
set(gca,'XLim',[0 M],'YLim',[0 N])
grid on
clear
L=30;
M=30;
N=30;
time=10;
for s=1:3;
for t=1:time;
for i=1:L;
for j=1:M;
for k=1:N;
Q(i,j,k,t,s)=randn(1,1);
end
end
end
end
end
figure('Position',[10 10 1700 900])
contour(Q(:,:,1,3,2),12)
xlabel('x axis')
ylabel('y axis')
title('Plotting the Right Hand Side')
set(gca,'XLim',[0 M],'YLim',[0 N])
grid on
Unless otherwise noted, all content on this site is @Copyright by Ahmed Al Makky 2012-2013 - http://cfd2012.com