I'm complitily lost with that error: Error using horzcat Dimensions of matrices being concatenated are not consistent
Show older comments
I have that code, to do some mathematic problem:
ER = 1.0;
EO = 8.8541e-12;
VO = 1.0;
AA = 0.001;
L = 1.0;
N = 20;
DELTA = L/N;
%--------------------------
% Matrix A
%--------------------------
I = 1:N;
Y = DELTA*(I-0.5);
for i = 1:N
for j = 1:N
if (i ~= j)
A(i,j) = DELTA/abs(Y(i)-Y(j));
else
A(i,j) = 2.0*log(DELTA/AA);
end
end
end
%---------------------
% Vector B
%-------------------
B = 4.0*pi*EO*ER*VO*ones(N,1);
C = inv(A);
RHO = C*B;
SUM = 0.0;
for I=1:N
SUM = SUM + RHO(I);
end
Q = SUM*DELTA;
diary c:magMetMom.txt
[EO,Q]
[ [1:N] ' Y' RHO ]
diary off
%------------------
% Plot
%----------------
plot(Y,RHO)
xlabel('y (cm)'), ylabel('rho_L (pC/m)')
ERROR Message:
"ans =
1.0e-11 *
0.8854 0.8579
Error using horzcat
Dimensions of matrices being concatenated are not consistent."
DOES anyone can help? Tks a lot !! =))))
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!