Data dimensions must agree .求助MATLAB高手
来源:百度知道 编辑:UC知道 时间:2024/09/28 15:09:13
今天老师布置了一道MATLAB题,用迭代法求金属槽内电位分布。
程序如下
%Part 1: Initializing data;
Nx=4;
Ny=2;
Lx=4;
Ly=2;
Hx=Lx/Nx;
Hy=Ly/Ny;
alpha=1.17;
Nmax=160;
u=zeros(Nx+1,Ny+1);
%Part 2: Calculating coordinates for each point and applying loads at boundary;
x0=0;
y0=0;
for j=1:(Ny+1)
for i=1:(Nx+1)
k=(j-1)*(Ny+1)+i;
x(k)=x0+Hx*(i-1);
y(k)=y0+Hy*(j-1);
if abs(y(k)-y0)<1e-05
u(j,i)=0;
end;
if abs(x(k)-x0)<1e-05
u(j,i)=0;
end;
if abs(x(k)-x0-Lx)<1e-05
u(j,i)=0;
end;
if abs(y(k)-y0-Ly)<1e-05
u(j,i)=100;
end;
end;
end;
%Part 3: Calculating potential with iterating method;
Error_max=0;
Precision=1e-05;
for k=1:Nmax
Error_max=0;
for i=2:Ny
for j=2:Nx
u1=u(i,j);
u(i,j)=u(i,j)+alpha*(u(i+1,j)+u(i,j+1)+u(i-1,
程序如下
%Part 1: Initializing data;
Nx=4;
Ny=2;
Lx=4;
Ly=2;
Hx=Lx/Nx;
Hy=Ly/Ny;
alpha=1.17;
Nmax=160;
u=zeros(Nx+1,Ny+1);
%Part 2: Calculating coordinates for each point and applying loads at boundary;
x0=0;
y0=0;
for j=1:(Ny+1)
for i=1:(Nx+1)
k=(j-1)*(Ny+1)+i;
x(k)=x0+Hx*(i-1);
y(k)=y0+Hy*(j-1);
if abs(y(k)-y0)<1e-05
u(j,i)=0;
end;
if abs(x(k)-x0)<1e-05
u(j,i)=0;
end;
if abs(x(k)-x0-Lx)<1e-05
u(j,i)=0;
end;
if abs(y(k)-y0-Ly)<1e-05
u(j,i)=100;
end;
end;
end;
%Part 3: Calculating potential with iterating method;
Error_max=0;
Precision=1e-05;
for k=1:Nmax
Error_max=0;
for i=2:Ny
for j=2:Nx
u1=u(i,j);
u(i,j)=u(i,j)+alpha*(u(i+1,j)+u(i,j+1)+u(i-1,
X、Y与u的大小不同。
>> whos
Name Size Bytes Class Attributes
X 3x5 120 double
Y 3x5 120 double
u 5x5 200 double
>> X
X =
0 1 2 3 4
0 1 2 3 4
0 1 2 3 4
>> Y
Y =
0 0 0 0 0
1 1 1 1 1
2 2 2 2 2
>> u
u =
0 0 0 0 0
0 35.7143 42.8571 35.7143 0
100.0000 100.0000 100.0000 100.0000 100.0000
0 0 0 0 0
0 0 0 0 0
Data dimensions must agree .求助MATLAB高手
size,pins,dimensions怎么翻译
Hofstede's four cultural dimensions
Adobe Dimensions 3.0.exe是什么软件
Data data=new Data()什么意思
Does anyone know Hofstede’s study of cultural dimensions?
Index exceeds matrix dimensions翻译成汉语是什么意思
Dimensions or Features critical to performance or assembly fit
THE MODEL DIMENSIONS EXCEED THE CAPACITY OF THIS VERSION.
data 是什么意思