Subscripted assignment dimension mismatch

I got error 'Subscripted assignment dimension mismatch' for the following code:
for i = 1 : 2
for k = 1: 4
tmp3_=val(['importdata(''./Output/THOutput/Run',num2str(i),'/GM',num2str(k),'/pileDisp','.out'')']);
nPileNode = (size(tmp3_, 2)-1) / 3;
for n=1 : nPileNode
dispPileNodes_X(: , n)=tmp3_( : , (n-1) * 3 + 2 );
dispPileNodes_Y(: , n)=tmp3_( : , (n-1) * 3 + 3 );
end
Max_dispPileNodes_X =max(abs(dispPileNodes_X),[],2);
Max_dispPileNodes_Y =max(abs(dispPileNodes_Y),[],2);
Max_max_dispPileNodes_X(i,k) = max(abs(Max_dispPileNodes_X));
Max_max_dispPileNodes_Y(i,k) = max(abs(Max_dispPileNodes_Y));
end
end

답변 (1개)

Walter Roberson
Walter Roberson 2018년 5월 21일

0 개 추천

We have no information about what your val() function does.
This code looks suspiciously close to using eval() for no good reason.
thisfile = sprintf('./Output/THOutput/Run%d/GM%d/pileDisp.out', i, k);
tmp3_ = importdata(thisfile);
Note: we have no idea what the size of the input data is, or what size you initialized dispPileNodes_* to. Or which line the error is occurring on.

댓글 수: 4

Mos_bad
Mos_bad 2018년 5월 21일
편집: Walter Roberson 2018년 5월 21일
the error is occurring on the lines :
Max_max_dispPileNodes_X(i,k) = max(abs(Max_dispPileNodes_X));
Max_max_dispPileNodes_Y(i,k) = max(abs(Max_dispPileNodes_Y));
Either dispPileNodes_X is somehow 3D, or nPileNode < 1 and dispPileNodes_X was initialized to empty.
Mos_bad
Mos_bad 2018년 5월 21일
dispPileNodes_X is 2D and nPileNode=88
Time to use the debugger.
dbstop if error
Run the code. When it errors out, check that i and k are scalars and that Max_dispPileNodes_X is a non-empty vector.

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

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2018년 5월 21일

댓글:

2018년 5월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by