Example
clc
clear
rr=1;
L=2*pi*rr;
M=100;
dtheta=L/M;
a=1;
theta(1)=-dtheta;
for i=1:M+1;
theta(i+1)=theta(i)+dtheta;
x(i)=2*a*(1+cos(theta(i+1)))*cos(theta(i+1));
y(i)=2*a*(1+cos(theta(i+1)))*sin(theta(i+1));
end
plot(x(1:M+1),y(1:M+1))
axis equal
grid on
clear
rr=1;
L=2*pi*rr;
M=100;
dtheta=L/M;
a=1;
theta(1)=-dtheta;
for i=1:M+1;
theta(i+1)=theta(i)+dtheta;
x(i)=2*a*(1+cos(theta(i+1)))*cos(theta(i+1));
y(i)=2*a*(1+cos(theta(i+1)))*sin(theta(i+1));
end
plot(x(1:M+1),y(1:M+1))
axis equal
grid on
Example
clc
clear
rr=1;
L=2*pi*rr;
M=100;
dtheta=L/M;
a=1;
theta(1)=-dtheta;
for i=1:M+1;
theta(i+1)=theta(i)+dtheta;
x(i)=a*cos(theta(i+1))*cos(3*(theta(i+1)));
y(i)=a*cos(3*(theta(i+1)))*(sin(theta(i+1)));
end
plot(x(1:M+1),y(1:M+1))
axis equal
grid on
clear
rr=1;
L=2*pi*rr;
M=100;
dtheta=L/M;
a=1;
theta(1)=-dtheta;
for i=1:M+1;
theta(i+1)=theta(i)+dtheta;
x(i)=a*cos(theta(i+1))*cos(3*(theta(i+1)));
y(i)=a*cos(3*(theta(i+1)))*(sin(theta(i+1)));
end
plot(x(1:M+1),y(1:M+1))
axis equal
grid on
Example
clc
clear
rr=1;
L=5*pi*rr;
M=200;
dtheta=L/M;
a=1;
theta(1)=-dtheta;
for i=1:M+1;
theta(i+1)=theta(i)+dtheta;
x(i)=a*cos(theta(i+1))*theta(i+1);
y(i)=a*theta(i+1)*(sin(theta(i+1)));
end
plot(x(1:M+1),y(1:M+1))
axis equal
grid on
clear
rr=1;
L=5*pi*rr;
M=200;
dtheta=L/M;
a=1;
theta(1)=-dtheta;
for i=1:M+1;
theta(i+1)=theta(i)+dtheta;
x(i)=a*cos(theta(i+1))*theta(i+1);
y(i)=a*theta(i+1)*(sin(theta(i+1)));
end
plot(x(1:M+1),y(1:M+1))
axis equal
grid on
Example
clc
clear
a=0;
b=0;
c=0;
d=0;
for i=1:12;
%odd even selection criterial on off relation
a=a+1;
x(a)=randn(1,1);
t(a)=rem(a,2);
if (t(a)==1)
b=b+1;
z(b)=x(a);
elseif (t(a)==0)
c=c+1;
zz(b)=x(a);
end
% This sees that the condition is atisfied and then changes the value
% of the orignal matrix and stores the value that was changed in an
% endependent matrix
if (x(a)>0.2)
d=d+1;
zzz(d)=x(a);
x(a)=0;
end
end
z';
x';
t';
zz';
d
zzz'
x'
y=[1:1:12];
rank(z);
plot(y,t)
clear
a=0;
b=0;
c=0;
d=0;
for i=1:12;
%odd even selection criterial on off relation
a=a+1;
x(a)=randn(1,1);
t(a)=rem(a,2);
if (t(a)==1)
b=b+1;
z(b)=x(a);
elseif (t(a)==0)
c=c+1;
zz(b)=x(a);
end
% This sees that the condition is atisfied and then changes the value
% of the orignal matrix and stores the value that was changed in an
% endependent matrix
if (x(a)>0.2)
d=d+1;
zzz(d)=x(a);
x(a)=0;
end
end
z';
x';
t';
zz';
d
zzz'
x'
y=[1:1:12];
rank(z);
plot(y,t)
Fourier Analysis Plots
clc
clear
x0=0;
x00=1;
y0=0;
m=1;
N=120;
dx=(x00-x0)/N;
for i=1:N;
x(i)=i*dx;
c(i)=y0-m*x0;
y(i)=m*x(i)+c(i);
end
plot(y,x)
xlabel('X')
ylabel('Y')
grid on
axis equal
hold on
x0=-1;
x00=0;
y0=0;
m=1;
N=120;
dx=(x00-x0)/N;
for i=1:N;
x(i)=i*dx;
c(i)=y0-m*x0;
y(i)=m*x(i)+c(i);
end
plot(y,x)
hold on
x0=-2;
x00=-1;
y0=0;
m=1;
N=120;
dx=(x00-x0)/N;
for i=1:N;
x(i)=i*dx;
c(i)=y0-m*x0;
y(i)=m*x(i)+c(i);
end
plot(y,x)
hold on
x0=-3;
x00=-2;
y0=0;
m=1;
N=120;
dx=(x00-x0)/N;
for i=1:N;
x(i)=i*dx;
c(i)=y0-m*x0;
y(i)=m*x(i)+c(i);
end
plot(y,x)
clear
x0=0;
x00=1;
y0=0;
m=1;
N=120;
dx=(x00-x0)/N;
for i=1:N;
x(i)=i*dx;
c(i)=y0-m*x0;
y(i)=m*x(i)+c(i);
end
plot(y,x)
xlabel('X')
ylabel('Y')
grid on
axis equal
hold on
x0=-1;
x00=0;
y0=0;
m=1;
N=120;
dx=(x00-x0)/N;
for i=1:N;
x(i)=i*dx;
c(i)=y0-m*x0;
y(i)=m*x(i)+c(i);
end
plot(y,x)
hold on
x0=-2;
x00=-1;
y0=0;
m=1;
N=120;
dx=(x00-x0)/N;
for i=1:N;
x(i)=i*dx;
c(i)=y0-m*x0;
y(i)=m*x(i)+c(i);
end
plot(y,x)
hold on
x0=-3;
x00=-2;
y0=0;
m=1;
N=120;
dx=(x00-x0)/N;
for i=1:N;
x(i)=i*dx;
c(i)=y0-m*x0;
y(i)=m*x(i)+c(i);
end
plot(y,x)
Example
clc
clear
x0=-5;
y0=0;
x00=0;
dx0=-5;
dy0=0;
dx00=-5;
m=1;
N=120;
for j=1:12;
x0=x0+dx0;
y0=y0+dy0;
x00=x00+dx00;
dx=(x00-x0)/N;
k=-60;
for i=1:N;
k=k+1;
x(i)=k*dx;
c(i)=y0-m*x0;
y(i)=m*x(i)+c(i);
end
plot(y,x)
xlabel('X')
ylabel('Y')
grid on
axis equal
hold on
end
clear
x0=-5;
y0=0;
x00=0;
dx0=-5;
dy0=0;
dx00=-5;
m=1;
N=120;
for j=1:12;
x0=x0+dx0;
y0=y0+dy0;
x00=x00+dx00;
dx=(x00-x0)/N;
k=-60;
for i=1:N;
k=k+1;
x(i)=k*dx;
c(i)=y0-m*x0;
y(i)=m*x(i)+c(i);
end
plot(y,x)
xlabel('X')
ylabel('Y')
grid on
axis equal
hold on
end
Plotting Heavy Side Function
clc
clear
x0=0;
y0=0;
x00=1;
y00=0;
x=1;
y=1;
x1=2;
y1=1;
x2=2;
y2=0;
v1=[ x0 x00 ]
v2=[ y0 y00 ]
f=line(v1,v2)
v3=[ x x1 ]
v4=[ y y1 ]
f1=line(v3,v4)
v5=[ x00 x ]
v6=[ y00 y ]
f2=line(v5,v6)
v7=[ x1 x2 ]
v8=[ y1 y2 ]
f3=line(v7,v8)
grid on
figure(1)
title('Heavy side')
xlabel('x')
ylabel('y')
clear
x0=0;
y0=0;
x00=1;
y00=0;
x=1;
y=1;
x1=2;
y1=1;
x2=2;
y2=0;
v1=[ x0 x00 ]
v2=[ y0 y00 ]
f=line(v1,v2)
v3=[ x x1 ]
v4=[ y y1 ]
f1=line(v3,v4)
v5=[ x00 x ]
v6=[ y00 y ]
f2=line(v5,v6)
v7=[ x1 x2 ]
v8=[ y1 y2 ]
f3=line(v7,v8)
grid on
figure(1)
title('Heavy side')
xlabel('x')
ylabel('y')
Unless otherwise noted, all content on this site is @Copyright by Ahmed Al Makky 2012-2013 - http://cfd2012.com