roei
Newbie level 3
I need to draw a triangele inside a circle. the triangele need to be in the center.
the potenzial inside=100 and outside=0
R=80
a=40 width of triangele
this is my work in matlab but I can't defined the triangele in the center.
clear all;
s1=80;
close all;
s2=80;
radius=80;
dx=0.5;
%mx=(-s1/2):dxs1/2);
%my=(-s2/2):dxs2/2);
mx=(-20):dx20);
my=(-20):dx20);
int_pot=110;
ext_pot=10;
%V=zeros(s2/dx,s1/dx);
V=zeros(160,160)
%external triangel
%for i=s1/(2*dx):-1:0
% for j=0s2/dx)
% if ((s1/(2*dx))-i>j/2)
%ניסוי מס 1
for i=20:-1:0
for j=040)
if (((20))-i>j/2)
V(j+1,i+1)=0;
else
V(j+1,i+1)=int_pot;%
end
end
end
%המשך ניסוי
for i=(20)40)
for j=040)
if (i-(20)>j/2)
V(j+1,i+1)=0;
else
V(j+1,i+1)=int_pot;%
end
end
end
%for i=(s1/(2*dx))s1/dx)
% for j=0s2dx)
% if (i-(s1/(2*dx))>j/2)
% V(j+1,i+1)=0;
% else
% V(j+1,i+1)=int_pot;%
%end
% end
%end
%vx=(-s1/2):dxs1/2);
%vy=(-s2/2):dxs2/2);
%[xx,yy]=meshgrid(vx,vy);
%xx_size=size(xx);
%bb=(radius^2)*ones(xx_size);
%[xxx,yyy]=meshgrid(vx.^2,vy.^2);
%[ix,iy]=find(bb>=yyy+xxx);
%
vx=(-s1):dxs1);
vy=(-s2):dxs2);
[xx,yy]=meshgrid(vx,vy);
xx_size=size(xx);
bb=(radius^2)*ones(xx_size);
[xxx,yyy]=meshgrid(vx.^2,vy.^2);
[ix,iy]=find(bb>=yyy+xxx);
%עיגול
length_xy=length(ix);
for k=1:length_xy
V(ix(k),iy(k))=ext_pot;%
end
size_v=size(V);
V2=V;
V3=V;
iter=80;
for q = 1:iter
for n = 2size_v(1) - 1)
for m = 2size_v(2) - 1)
if V2(n,m) == 2
V(n,m) = 0.25*(V(n+1,m) + V(n - 1,m) + V(n,m + 1) + V(n,m - 1));
end
end
end
end
[u,v]=gradient(V,dx);
[xxx,yyy]=meshgrid(vx,vy);
figure(1)
mesh(vx,vy,V);
figure(2);
imagesc(vx,vy,V);
figure(3);
contour(V,40);
figure(4);
quiver(xxx,yyy,u,v,1.5);
thank you.
the potenzial inside=100 and outside=0
R=80
a=40 width of triangele
this is my work in matlab but I can't defined the triangele in the center.
clear all;
s1=80;
close all;
s2=80;
radius=80;
dx=0.5;
%mx=(-s1/2):dxs1/2);
%my=(-s2/2):dxs2/2);
mx=(-20):dx20);
my=(-20):dx20);
int_pot=110;
ext_pot=10;
%V=zeros(s2/dx,s1/dx);
V=zeros(160,160)
%external triangel
%for i=s1/(2*dx):-1:0
% for j=0s2/dx)
% if ((s1/(2*dx))-i>j/2)
%ניסוי מס 1
for i=20:-1:0
for j=040)
if (((20))-i>j/2)
V(j+1,i+1)=0;
else
V(j+1,i+1)=int_pot;%
end
end
end
%המשך ניסוי
for i=(20)40)
for j=040)
if (i-(20)>j/2)
V(j+1,i+1)=0;
else
V(j+1,i+1)=int_pot;%
end
end
end
%for i=(s1/(2*dx))s1/dx)
% for j=0s2dx)
% if (i-(s1/(2*dx))>j/2)
% V(j+1,i+1)=0;
% else
% V(j+1,i+1)=int_pot;%
%end
% end
%end
%vx=(-s1/2):dxs1/2);
%vy=(-s2/2):dxs2/2);
%[xx,yy]=meshgrid(vx,vy);
%xx_size=size(xx);
%bb=(radius^2)*ones(xx_size);
%[xxx,yyy]=meshgrid(vx.^2,vy.^2);
%[ix,iy]=find(bb>=yyy+xxx);
%
vx=(-s1):dxs1);
vy=(-s2):dxs2);
[xx,yy]=meshgrid(vx,vy);
xx_size=size(xx);
bb=(radius^2)*ones(xx_size);
[xxx,yyy]=meshgrid(vx.^2,vy.^2);
[ix,iy]=find(bb>=yyy+xxx);
%עיגול
length_xy=length(ix);
for k=1:length_xy
V(ix(k),iy(k))=ext_pot;%
end
size_v=size(V);
V2=V;
V3=V;
iter=80;
for q = 1:iter
for n = 2size_v(1) - 1)
for m = 2size_v(2) - 1)
if V2(n,m) == 2
V(n,m) = 0.25*(V(n+1,m) + V(n - 1,m) + V(n,m + 1) + V(n,m - 1));
end
end
end
end
[u,v]=gradient(V,dx);
[xxx,yyy]=meshgrid(vx,vy);
figure(1)
mesh(vx,vy,V);
figure(2);
imagesc(vx,vy,V);
figure(3);
contour(V,40);
figure(4);
quiver(xxx,yyy,u,v,1.5);
thank you.