求助!看看这个程序有什么问题?运行不出结果!!
clearh=1;
v0=100;
hx=16;
hy=10;
v1=zeros(hy,hx);
v1(hy,:)=ones(1,hx)*v0;
v1(2:hy-1,2:hx-1)=ones(hy-2,hx-2)*v0/2;
v2=zeros(hy,hx);
for i=1:hy
for j=1:hx
if i==hy
v2(i,j)=v0;
elseif i==1|j==1|j==hx
v2(i,j)=0;
else
v2(i,j)=/4;
end
end
end
for k=1:500
v1=v2;
for i=1:hy
for j=1:hx
if i==hy
v2(i,j)=0;
elseif i==1|j==1|j==hx
v2(i,j)=0;
else
v2(i,j)=/4;
end
end
end
subplot(1,2,1),mesh(v2)
h1=mesh(v2);
set(h1,'linewidth',1,'edgecolor','b')
text(-6,10,120,'v','fontsize',10);
text(-4,12,0,'h','fontsize',10);
text(18,0,0,'b','fontsize',10);
hold on
axis();
subplot(1,2,2),
contour(v2,'k-')
text(-2,10,'h','fontsize',10);
text(17,1,'b','fontsize',10);
hold on
[ 本帖最后由 lxq 于 2006-11-22 21:31 编辑 ] 少了一个end,给改如下
clear
h=1;
v0=100;
hx=16;
hy=10;
v1=zeros(hy,hx);
v1(hy,:)=ones(1,hx)*v0;
v1(2:hy-1,2:hx-1)=ones(hy-2,hx-2)*v0/2;
v2=zeros(hy,hx);
for i=1:hy
for j=1:hx
if i==hy
v2(i,j)=v0;
elseif i==1|j==1|j==hx
v2(i,j)=0;
else
v2(i,j)=/4;
end
end
end
for k=1:500
v1=v2;
for i=1:hy
for j=1:hx
if i==hy
v2(i,j)=0;
elseif i==1|j==1|j==hx
v2(i,j)=0;
else
v2(i,j)=/4;
end
end
end
end
subplot(1,2,1),mesh(v2)
h1=mesh(v2);
set(h1,'linewidth',1,'edgecolor','b')
text(-6,10,120,'v','fontsize',10);
text(-4,12,0,'h','fontsize',10);
text(18,0,0,'b','fontsize',10);
hold on
axis();
subplot(1,2,2),
contour(v2,'k-')
text(-2,10,'h','fontsize',10);
text(17,1,'b','fontsize',10);
hold on 这都能看出来,厉害
页:
[1]