필터 지우기
필터 지우기

Error: Row index exceeds table dimensions.

조회 수: 4 (최근 30일)
Salma fathi
Salma fathi 2022년 6월 16일
답변: Peter Perkins 2022년 6월 16일
Hello, I am stuck at some point with this error . I am attaching a small sample of the file that contains the table SOLARL that is used in the code below, I am unable to attach all of it since it has a huge size.
The error accur when the loop index ii=5788 but before that it runs fine. And the length of the table 'dates' is 16590.
%data is stored in the table SOLARL
SOLARL.Date2 = datenum(SOLARL.Date);
%finding the unique dates that are in the table SOLARL
dates = unique(SOLARL.Date2);
PeakTable=[];
for ii = 1:length(dates)
fprintf('.......... table - %d of %d\n',ii, length(dates));
%iteratively, the data of each unique day is stored in the table tDate to be processed
tDate = SOLARL(SOLARL.Date2 == dates(ii), :);
tDate.Date2 = [];
tDate.Date = [];
%this loop will go through the table tDate and find the peak point
%according to a certain craiteria.
EDP=table2array(tDate);
for ied=1:length(EDP)
imax=[];
[~,imax] = max(EDP(:,7));
if (EDP(imax,6) < 190 || EDP(imax,6) >400)
EDP(imax,:)=[];
elseif ( EDP(imax,6) > 190 && EDP(imax,6) < 190)
break;
end
end
b=imax;
y=tDate.GDALT;
%To find the indices of the data rows of the points that are above and below the peak point
peak_y = tDate.GDALT(b) ;
idxl = y < peak_y ;
idxh = y > peak_y ;
numOfPointsL= length(y(idxl));
numOfPointsH= length(y(idxh));
%according to how many points there are, we extract only 20% of them
ExtractedNumPointsL=int8(0.2*numOfPointsL);
ExtractedNumPointsH=int8(0.2*numOfPointsH);
%the table pt will have the extracted rows that are above and below the
%peak point and the peak point stored in it.
pt=tDate(b-ExtractedNumPointsL: b+ExtractedNumPointsH,:); % here is the error
PeakTable=[PeakTable; pt];
end
  댓글 수: 2
MJFcoNaN
MJFcoNaN 2022년 6월 16일
Hello,
Please post the whole error information from matlab.
Salma fathi
Salma fathi 2022년 6월 16일
this is the only message I am getting
Error using PeakConstruction (line 172)
Row index exceeds table dimensions.

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

답변 (1개)

Peter Perkins
Peter Perkins 2022년 6월 16일
SOLARL.Date2 = datenum(SOLARL.Date);
DON'T do that. Just use datetime. You can call unique, length, and == a on datetime vector.
Also, it appears that your outer loop can just be a grouped (by day) calculation using, probably, rowfun, or maybe groupsummary. Pretty hard to follow your code, so not sure exactly what that would look like.

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by