How can I solve the problem 'Subscripted assignment dimension mismatch' in my looping progress?
古いコメントを表示
I want to write vector to an array (matrix), but I get problem in the dimension of it. ntr is the number of trace. this is my code:
for i=1:ntr % read traces into panel
[seis(:,i),seqno(i),itr(i),irec(i),dt,offset,sdepth,selev,relev(i),...
xs,ys,xr(i),yr(i),cdp(i)]=segyin(fid);
if i==1
cdp(i) % list cdp as progress flag
end
if (ixs == 0)
xoff=[xoff;offset]; % build offset vector
else
xoff = [xoff;10*(i-1)-1500];
end
here is the error:
Subscripted assignment dimension mismatch.
Error in trpan (line 152)
[seis(:,i),seqno(:,i),itr(i),irec(i),dt,offset,sdepth,selev,relev(i),...
回答 (2 件)
Walter Roberson
2015 年 10 月 6 日
0 投票
In the error message, the first output is given as seis(nsamp,i), but in the code segment, the first output is given as seis(:,i) . The code you are running is not the same as the code you posted.
Note that we do not know anything about segyin() and we do not know how you initialized your variables.
1 件のコメント
Kiswanto Ihsani
2015 年 10 月 6 日
編集済み: Walter Roberson
2015 年 10 月 6 日
Thorsten
2015 年 10 月 6 日
The error seems to be due to the first two arguemnts. Try
[a,b,itr(i),irec(i),dt,offset,sdepth,selev,relev(i),...
xs,ys,xr(i),yr(i),cdp(i)]=segyin(fid);
whos a
whos b
What's the result? That may give you some idea of how to correct the code.
5 件のコメント
Kiswanto Ihsani
2015 年 10 月 6 日
Walter Roberson
2015 年 10 月 6 日
nsamp is somehow invalid, such as if it is negative. You are reading it as 'short' which is a signed value.
Kiswanto Ihsani
2015 年 10 月 6 日
Thorsten
2015 年 10 月 6 日
What's the value of nsamp? Could it be 0?
Kiswanto Ihsani
2015 年 10 月 6 日
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!