function myrectangularmesh
%
clear all
x=0:10;y=0:10;
X0=1;Y0=1;
n1=0;
z=zeros(11,11);
for i=0:10;
for j=0:10
n1=n1+1;
x(n1)=i*X0;
y(n1)=j*Y0;
z(i+1,j+1)=n1;
end
end
ndm=n1;
for i=1:11
for j=1:11
L=0;a=0;
k5=z(i,j);
if i-1>0
L=L+1;
k1=z(i-1,j);
AA(k5,k1)=-1;
end
if j-1>0
L=L+1;
k2=z(i,j-1);
AA(k5,k2)=-1;
end
if i+1<=11
L=L+1;
k3=z(i+1,j);
AA(k5,k3)=-1;
end
if j+1<=11
L=L+1;
k4=z(i,j+1);
AA(k5,k4)=-1;
end
AA(k5,k5)=L;
end
end
hold on
AA=sparse(AA);
BB=full(AA);
figure(1);
xy=;
size(xy);
gplot(AA,xy)
axis equal,axis tight
set(gca,'xtick',)
set(gca,'xticklabel',{'0';'1';'2';'3';'4';'5';'6';'7';'8';'9';'10'}) 难道楼主是要这样?
x = (-2:.2:2);
y = (-1.5:.2:1.5)';
X = x(ones(size(y)),:);
Y = y(:,ones(size(x)));
F = X.*exp(-X.^2-Y.^2);
它与
= meshgrid(-2:.2:2, -1.5:.2:1.5);
F = X .* exp(-X.^2 - Y.^2);
是等价的 若要用类C语言编写,楼主看这样行不?
function =mesh_grid(x,y)
x=1:3;y=2:4;
xLen=length(x);yLen=length(y);
X=zeros(yLen,xLen);Y=X;
for b=1:xLen
X(:,b)=x(b);
end
for a=1:yLen
Y(a,:)=y(a);
end 如何在三角形区域划分三角形网格呢?请高手指点一下! 学习了感谢大家分享
页:
1
[2]