"Subscripted assignment dimension mismatch"?

I'm unable to figure out where this error is coming about in this block of code. Any help would be great. Thank you.
%%Write data to a file (requires writeM2T.m)
cnt=0;
cnt2=0;
ind = [1 2 3 4 5 -win:win];
for i=1:length(Ndya)
for j=1:Nepi
if ~isempty(data(i,j).MOM)
if ~isempty(data(i,j).BABY)
cnt=cnt+1;
OUTcrqa(cnt,:) = [i j data(i,j).crqa];
OUTlagp(cnt,:) = [i j data(i,j).crqaBS];
for k = 1:max(size(data(i,j).crqaCI))
cnt2=cnt2+1;
OUTcrqaCI(cnt2,:) = [i j data(i,j).crqaCI(k,:) ind(k)];
end
end
end
end
end
cd(yourpath)
save('CRQAoutput.mat')
hdr1={'dyad','episode','RR','DET','<L>','Lmax','ENTR','LAM','TT','Vmax','T1','T2','RTE','Clust','Trans'};
writeM2T(OUTcrqa,'outCRQA.dat',hdr1,[],[],'w')
%hdr2=[{'dyad','episode'} {num2cell(-win:win)}];
writeM2T(OUTlagp,'outLAGPcrqad.dat',[],[],[],'w')
% Bootstrapped CI
hdr3={'dyad','episode','CI_U','CI_L','Measure'};
writeM2T(OUTcrqaCI,'outBSCI.dat',hdr3,[],[],'w')

댓글 수: 8

Erik S.
Erik S. 2015년 2월 18일
Which line is the error? What are the sizes of the variables?
Akhila
Akhila 2015년 2월 18일
That's what I'm having trouble with, it doesn't tell me which line, When I run this section, this error pops up. Is there a way for me to identify the line that there is an error?
Erik S.
Erik S. 2015년 2월 18일
Look in the Matlab command window, it usually says which line the error occured.
Akhila
Akhila 2015년 2월 18일
Yes, looked there - can't seen to identify a line. Any other ideas? Thank you.
Erik S.
Erik S. 2015년 2월 18일
can you send the code?
Sure, this is the entire code. All the sections prior to the last one are running fine.
%% INITIATE VARIABLES
% Set the path to where the data are (assuming there are mom and baby subfolders) yourpath = 'C:\Users\Akhila\Documents\MATLAB\TS16W\TS16WDyads';
%This is a vector of the dyad numbers to analyze Ndya = {'0115','0126','0132','0162','0181','0194','0206','0226','0241','0252','0254','0255','0259','0261','0268','0274','0287','0294','0296','0297','0299','0300','0303','0305','0310','0311','0312','0319','0326','0329','0342','0355','0364','0371','0372','0381','0384','0386','0398','0399','0401','0424','0427','0436','0443','0446','0477','0488','0490','0493','0494','0507','0510','0520','0527','0530','0531','0537','0549','0554','0555','0568','0616','0624','0642','0670','0686','0719'};
%Enter the max. number of episodes to analyze Nepi = 5;
% CRQA settings dim = 3; lag = 10; rr = .10; lmin = 2; vmin = 2; tw = 1; win = 15;
% Strings to generate filename prefix ='TS16W'; midMOM ='0SF_E'; midBABY ='1SF_E'; suffix = '.txt';
%% READ DATA
for i=1:length(Ndya) for j=1:Nepi
data(i,j).dyad = Ndya{i};
data(i,j).episode = j;
cd([yourpath]);
filename = [prefix,Ndya{i},midMOM,num2str(j),suffix];
if exist(filename,'file')
data(i,j).MOM.raw = importdata(filename);
data(i,j).MOM.ID = filename;
cd([yourpath]);
filename = [prefix,Ndya{i},midBABY,num2str(j),suffix];
data(i,j).BABY.raw = importdata(filename);
data(i,j).BABY.ID = filename;
end
end
end
% Save the data so far cd(yourpath) save('CRQAoutput.mat')
%% PERFORM CRQA(D)
Nboot = 2500; Exceptions = 0; Warnings = 0;
fprintf('\n') disp('------Start CRQA analysis------') fprintf('\n')
for i=1:length(Ndya) for j=1:Nepi
if ~isempty(data(i,j).MOM)
if ~isempty(data(i,j).BABY)
fprintf('\n')
fprintf('Dyad: %s, Episode %u',Ndya{i},j);
fprintf('\n')
if length(data(i,j).MOM.raw)>length(data(i,j).BABY.raw)
data(i,j).MOM.raw(length(data(i,j).BABY.raw)+1:length(data(i,j).MOM.raw))=[];
fprintf('\n')
disp('WARNING: Timeseries unequal length... trimming')
fprintf('\n')
Warnings = Warnings +1;
end
if length(data(i,j).BABY.raw)>length(data(i,j).MOM.raw)
data(i,j).BABY.raw(length(data(i,j).MOM.raw)+1:length(data(i,j).BABY.raw))=[];
fprintf('\n')
disp('WARNING: Timeseries unequal length... trimming')
fprintf('\n')
Warnings = Warnings +1;
end
try
% Rescale to max distance
data(i,j).MOM.maxd = (100*data(i,j).MOM.raw)./pss(data(i,j).MOM.raw,dim,lag,'maxnorm');
data(i,j).BABY.maxd = (100*data(i,j).BABY.raw)./pss(data(i,j).BABY.raw,dim,lag,'maxnorm');
% CRP
data(i,j).crp = crp(data(i,j).MOM.maxd,data(i,j).BABY.maxd,dim,lag,rr,'rr','nonormalize','nogui');
% CRQA
data(i,j).crqa= crqa(data(i,j).MOM.maxd,data(i,j).BABY.maxd,dim,lag,rr,[],[],lmin,vmin,tw,'rr','nonormalize','nogui');
% Get CI by Bootstrapping
disp('Bootstrapping CRQA...')
[data(i,j).crqaBS,data(i,j).crqaCI,data(i,j).crqaCIlabels] = rqaci(data(i,j).crp,Nboot,5,tw,lmin,vmin,win);
if max(size(data(i,j).crp)) > 2*win
% Get diagonal profile using crqad (produces same output for RR as rqaci.m)
data(i,j).lagprof = crqad(data(i,j).MOM.maxd,data(i,j).BABY.maxd,dim,lag,rr,win,'rr','nonormalize','nogui');
else
fprintf('\n')
disp('WARNING: RP is too small for lag window!!!')
fprintf('\n')
Warnings = Warnings +1;
end
catch ME
ME
Exceptions = Exceptions + 1;
end
end
end
end
end
fprintf('\n') fprintf('Finished with %u exception(s)',Exceptions); fprintf('\n') fprintf('Finished with %u warning(s)',Warnings); fprintf('\n') fprintf('See Command Window for details'); fprintf('\n') fprintf('\n') disp('------Finished CRQA analysis------') fprintf('\n')
% Save data cd(yourpath) save('CRQAoutput.mat')
%% Write data to a file (requires writeM2T.m) cnt=0; cnt2=0; ind = [1 2 3 4 5 -win:win]; for i=1:length(Ndya) for j=1:Nepi
if ~isempty(data(i,j).MOM)
if ~isempty(data(i,j).BABY)
cnt=cnt+1;
OUTcrqa(cnt,:) = [i j data(i,j).crqa];
OUTlagp(cnt,:) = [i j data(i,j).crqaBS];
for k = 1:max(size(data(i,j).crqaCI))
cnt2=cnt2+1;
OUTcrqaCI(cnt2,:) = [i j data(i,j).crqaCI(k,:) ind(k)];
end
end
end
end
end
cd(yourpath) save('CRQAoutput.mat')
hdr1={'dyad','episode','RR','DET','<L>','Lmax','ENTR','LAM','TT','Vmax','T1','T2','RTE','Clust','Trans'}; writeM2T(OUTcrqa,'outCRQA.dat',hdr1,[],[],'w')
%hdr2=[{'dyad','episode'} {num2cell(-win:win)}]; writeM2T(OUTlagp,'outLAGPcrqad.dat',[],[],[],'w')
% Bootstrapped CI hdr3={'dyad','episode','CI_U','CI_L','Measure'}; writeM2T(OUTcrqaCI,'outBSCI.dat',hdr3,[],[],'w')
Erik S.
Erik S. 2015년 2월 18일
I cannot run this... there are files missing for me... Can you send all I need to run the hole thing!
Akhila
Akhila 2015년 2월 18일
Hi Erik, Attached is the whole folder. The .m file has the MATLAB code.

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

답변 (2개)

Erik S.
Erik S. 2015년 2월 18일

0 개 추천

Your sturcture data only contains the fields "dyad" and "episode" not "MOM" or "BABY"
When you get to line 67 the program crashes.

댓글 수: 1

Akhila
Akhila 2015년 2월 18일
aah, but won't the declarations in line 38, 39, 42, 43 suffice?

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

Erik S.
Erik S. 2015년 2월 18일

0 개 추천

Those lines 38-43 are never executed. The files you are looking for is in another folder than you .m file. Try to move them to the same folder.

댓글 수: 8

Akhila
Akhila 2015년 2월 18일
Alright, let me try that and get back to you. I don't get any errors till the last code section. So i'm really confused. Thank you so much.
Erik S.
Erik S. 2015년 2월 18일
Let me know if it doesnt work. If it works, pls click the accept answer button :)
Akhila
Akhila 2015년 2월 18일
sure thing.
Akhila
Akhila 2015년 2월 19일
Erik, that's not the problem. You received that error because I renamed the folder to send it to you and did not reset the path in the .m file. If you set that path correctly, you will not get these errors. Could you please try that? Then you will get the error I told you about to begin with. Thanks!
Erik S.
Erik S. 2015년 2월 19일
What was the original error for you? I get an error in line 154 now. But there seems to be other issues as well. There are 306 exetions with "ME", should it be like that?
Akhila
Akhila 2015년 2월 19일
Subscripted assignment dimension mismatch - this is the original error I was getting in the last block. What is the error in line 154?
Also, i get 30 warnings, no exceptions.
Erik S.
Erik S. 2015년 2월 19일
편집: Erik S. 2015년 2월 19일
The exceptions occurs because the function pss is undefined for arguments of type double it says. Is pss a function or a variable?
The error is:
Reference to non-existent field 'crqa'.
Error in TS16WCode (line 154) OUTcrqa(cnt,:) = [i j data(i,j).crqa];
Akhila
Akhila 2015년 2월 19일
i'm not getting those exceptions, so not sure what you are asking. I'm going to try some other things. Thank you for your help. I will be in touch if I can clarify the question further.

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

카테고리

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

태그

질문:

2015년 2월 18일

댓글:

2015년 2월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by