How can I solve the problem 'Subscripted assignment dimension mismatch' in my looping progress?

3 vues (au cours des 30 derniers jours)
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),...

Réponses (2)

Walter Roberson
Walter Roberson le 6 Oct 2015
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 commentaire
Kiswanto Ihsani
Kiswanto Ihsani le 6 Oct 2015
Modifié(e) : Walter Roberson le 6 Oct 2015
i have revised the code. i just copy from my trial and error method.
this is the original function of segyin
function [trc,seqno,itr,irec,dt,offset,sdepth,selev,relev,...
xs,ys,xr,yr,cdp]=segyin(fid)
% nsamp=length(trc);
%read the trace header
[stuff,count]=fread(fid,4,'int');
if(count<4)
trc=nan;
seqno=nan; itr=nan; irec=nan; dt=nan;
offset=nan; sdepth=nan; selev=nan; relev=nan;
xs=nan; ys=nan; xr=nan; yr=nan; cdp=nan;
return;
end
seqno=stuff(1); irec=stuff(3); itr=stuff(4);
stuff=fread(fid,4,'char');
cdp=fread(fid,1,'int');
stuff=fread(fid,4,'char');
code=fread(fid,1,'short');
stuff=fread(fid,6,'char');
stuff=fread(fid,4,'int');
offset=stuff(1);relev=stuff(2);selev=stuff(3);sdepth=stuff(4);
stuff=fread(fid,16,'char');
stuff=fread(fid,2,'short');
stuff=fread(fid,4,'int');
xs=stuff(1);ys=stuff(2);xr=stuff(3);yr=stuff(4);
lenunit=fread(fid,1,'short');
stuff=fread(fid,24,'char');
stuff=fread(fid,2,'short');
nsamp=stuff(1);dt=stuff(2)/1000000.;
%Note SEGY stores dt in microseconds
stuff=fread(fid,122,'char');
%trace header complete
%read in trace
trc=fread(fid,nsamp,'float');

Connectez-vous pour commenter.


Thorsten
Thorsten le 6 Oct 2015
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 commentaires
Thorsten
Thorsten le 6 Oct 2015
What's the value of nsamp? Could it be 0?
Kiswanto Ihsani
Kiswanto Ihsani le 6 Oct 2015
the value of nsamp is absolutely positive, based on the my previous experience, nsamp value more than 50.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by