필터 지우기
필터 지우기

For Error: ??? Index exceeds matrix dimensions.

조회 수: 1 (최근 30일)
Mohamed Elwakdy
Mohamed Elwakdy 2014년 4월 6일
편집: Mohamed Elwakdy 2014년 4월 6일
Dear Sir,
This part of my code...I don't know why I have this error "??? Index exceeds matrix dimensions"...
T =[];
for j = 41:41:492
S1Secondcell1 = x1Firstrow16 (j+1: j+j, :);
X1= S1Secondcell1 (:,1);
Y1 = S1Secondcell1(:,2);
p1 = polyfit(X1,Y1,20)
T = [T; p1];
end

답변 (3개)

per isakson
per isakson 2014년 4월 6일
편집: per isakson 2014년 4월 6일
You don't supply enough information to make it possible for us to find the cause of the error.
Here are some links on debugging in Matlab
Hint: what does
size( x1Firstrow16 )
return?

Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 6일
Check the sizes of your arrays
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 6일
Without your data, I can't find where is the error
Mohamed Elwakdy
Mohamed Elwakdy 2014년 4월 6일
Dear Azzi,
Thank you very much on your interest...
For the data file, please visit the website below:
https://docs.google.com/file/d/0B254WGMh1VZTLUMyOHRPdEdMUE4xc3JNX1Z2Qkg5QTZuSE04/edit
This is my full code:
load TCheckingclass6.txt;
Firstrow16 = TCheckingclass6(1,:);
x1Firstrow16 = vec2mat(Firstrow16,2); R = size(x1Firstrow16); % 538 rows and 2 columns
S1Secondcell41= x1Firstrow16(1:41,:); X1 = S1Secondcell41 (:,1); Y1 = S1Secondcell41 (:,2); p1 = polyfit(X1,Y1,20);
T =[];
for j = 41:41:492
S1Secondcell1 = x1Firstrow16 (j+1: j+j, :);
X2= S1Secondcell1 (:,1);
Y2 = S1Secondcell1(:,2);
p2 = polyfit(X2,Y2,20);
T = [T; p2];
end
Thank you very much

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


Roger Stafford
Roger Stafford 2014년 4월 6일
편집: Roger Stafford 2014년 4월 6일
I rather think your trouble is caused by the way you indexed the array 'x1Firstrow16'. Its rows are successively indexed as:
41:82
83:164
123:246
165:328
.......
493:984
These are overlapping each other more and more as j increases. Somehow I doubt if that is what you meant to do, and I doubt that the array has 984 rows. You can check that easily with the 'size' command.
  댓글 수: 1
Mohamed Elwakdy
Mohamed Elwakdy 2014년 4월 6일
편집: Mohamed Elwakdy 2014년 4월 6일
Dear Roger,
From these steps: for j = 41:41:492 S1Secondcell1 = x1Firstrow16 ( j+1: j+j , :); I am looking to have this output:
42:82
83:123
124:164 .......
If the codes above is wrong ... How can I fixed it??
Thank you very much

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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by