Matrix dimensions must agree.

??? Error using ==> plus
Matrix dimensions must agree.
Error in ==> assem at 28
K(t(i,:),t(i,:)) = K(t(i,:),t(i,:))+Ke;
Dear all, What the hell is this? what should I do? please help me out.
thanks
function [Ke]=bar3e(ex,ey,ez,ep)
%--------------------------------------------------------------------
E=ep(1); A=ep(2);
b=[ ex(2)-ex(1); ey(2)-ey(1); ez(2)-ez(1) ];
L=sqrt(b'*b);
Kle=E*A/L*[1 -1;
-1 1];
n=b'/L; G=[ n zeros(size(n));
zeros(size(n)) n ];
Ke=G'*Kle*G;
%--------------------------end--------------------------------
function [K,f]=assem(edof,K,Ke,f,fe)
%-------------------------------------------------------------
[nie,n]=size(edof);
t=edof(:,2:n);
for i = 1:nie
K(t(i,:),t(i,:)) = K(t(i,:),t(i,:))+Ke;
if nargin==5
f(t(i,:))=f(t(i,:))+fe;
end
end
%--------------------------end--------------------------------

댓글 수: 5

dpb
dpb 2014년 8월 17일
dbstop on error
Then
size(K(t(i,:),t(i,:)))
size(Ke)
They've got to be commensurate...and aren't presently.
size(K(t(i,:),t(i,:))) = 4 * 4
size(Ke) = 6 * 6
But I don't know how to fix it.
Can you help me??
what I should do?
Thanks you so much.
Matt J
Matt J 2014년 8월 17일
편집: Matt J 2014년 8월 17일
Only you can know how the code is supposed to behave. What dimensions do you expect these matrices to have?
Georgi Gergov
Georgi Gergov 2014년 8월 17일
See the matrix dimension , that is the problem.
Hamid
Hamid 2014년 8월 17일
편집: Hamid 2014년 8월 17일
size(K(t(i,:),t(i,:))) = 4 * 4
on the other hand I want
(K(t(i,:),t(i,:))) size
change to 6*6 but it seems K is 9*9 matrix!!!!
What should I do?
Thanks guys.

댓글을 달려면 로그인하십시오.

답변 (1개)

Rick Rosson
Rick Rosson 2014년 8월 17일

1 개 추천

doc dbstop
doc dbcont
doc dbquit
doc dbstep

댓글 수: 1

size(K(t(i,:),t(i,:))) = 4 * 4
on the other hand I want
(K(t(i,:),t(i,:))) size
change to 6*6 but it seems K is 9*9 matrix!!!!
What should I do?
Thanks guys.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2014년 8월 17일

편집:

2014년 8월 17일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by