我哪裏出錯了? 問題出在:R = sqrt(bsxfun(@ minus,XX,(XX)')。^ 2 + bsxfun(@ minus,YY,(YY)')。Matlab-Subscript索引必須是實數正整數或邏輯
EO = 8.8541e-12; %eps0
A2 = 1.0e-2; %2a
N = 100; %num of subareas in a plate
M = sqrt(N); %num of subareas in one axis
DX = A2/M; % 2b
DY = DX; %2b
DL = DX; %2b
% SECOND, CALCULATE THE ELEMENS OF THE COEFFICIENT MATRIX A
% Write all the subareas centers coordinates to X and Y
% SECOND, CALCULATE THE ELEMENS OF THE COEFFICIENT MATRIX A
% Write all the subareas centers coordinates to X and Y
x = linspace(DL*0.5,DL*(M-0.5),M);
y = x;
[XX,YY]=meshgrid(x,y);
%%L = NaN(N,N);
**R = sqrt(bsxfun(@minus,XX,(XX)').^2+bsxfun(@minus,YY,(YY)').^2);**
idx_diagL = find(eye(N)~=0);
idx_not_diagL = find(eye(N)==0);
L(idx_not_diagL) = DL^2./(4.*pi*EO*R(mod(idx_not_diagL,10),floor(idx_not_diagL/N)));
L(idx_diagL) = DL*0.8814/(pi*EO); %ln(1+sqrt(2)= 0.8814
另請參閱[此問題](http://stackoverflow.com/questions/20054047/subscript-indices-must-either-be-real-positive-integers-or-logicals-generic-sol)for [generic解決此問題的方法](http://stackoverflow.com/a/20054048/983722)。 –