Index exceeds matrix dimensions Error
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hello
I am trying to access data from a document and the data gets imported correctly. The array for data is a 20 x 20 size array, but when I try to access row 2, it gives the index exceeds matrix dimensions error.
Here is my code:
figure(1);
markers=['+' 'o' '*' '.' 'x' 's' 'd' '^' 'v' '<' '>' 'p' 'h'];
location = 1;
disp(size(data()));
for i=1:num_trials
for j=1:num_sensors
col = 5 + (j-.5) * 2;
plot(location * ones(size(data(:,col,i))),data(:,col,i),'.'); hold on;
end
location = location+1;
end
grid on;
The specific line generating the error is: plot(location * ones(size(data(:,col,i))),data(:,col,i),'.'); hold on;
채택된 답변
James Tursa
2015년 6월 29일
If "data" is 20x20, why are you indexing into it as a 3D array? E.g.,
data(:,col,i)
What are the values of num_trials and num_sensors? That could be another source of problems.
댓글 수: 7
Cory Morales
2015년 6월 29일
num_trials is 10 and num_sensors is 8
I had the colon there because i needed to get everything out of that location for the data collection. What would be a better way to do this?
James Tursa
2015년 6월 29일
What is "data"? A double array, cell array, or what?
Cory Morales
2015년 6월 29일
double with 1x1 struct cells of unknown struct type
James Tursa
2015년 6월 29일
This is not clear to me. Is it a struct with fields that are cell arrays that contain double arrays? Or what? E.g., what does class(data) return?
Data is taking in sensor data from a sensor strip. For example, when i run disp(data) i get:
Columns 1 through 10
10 2 1 119 28 4559 101 4570 58 4457
10 2 2 119 28 4545 100 4581 58 4450
10 2 3 119 29 4562 101 4572 58 4444
10 2 4 119 29 4552 102 4570 58 4444
10 2 5 119 28 4553 101 4566 58 4442
10 2 6 119 27 4557 100 4577 56 4456
10 2 7 119 26 4557 99 4570 56 4446
10 2 8 119 27 4555 100 4573 56 4455
10 2 9 119 27 4550 100 4575 56 4450
10 2 10 119 26 4560 99 4569 55 4449
10 2 1 119 28 4559 101 4569 58 4455
10 2 2 119 28 4564 101 4576 57 4452
10 2 3 119 28 4557 100 4577 57 4445
10 2 4 119 28 4557 100 4587 57 4449
10 2 5 119 27 4554 99 4573 57 4447
10 2 6 119 28 4559 99 4577 57 4451
10 2 7 119 27 4558 99 4565 56 4455
10 2 8 119 27 4552 99 4567 57 4441
10 2 9 119 27 4552 100 4577 57 4453
10 2 10 119 27 4556 100 4579 57 4449
Columns 11 through 20
147 4614 288 5109 98 4417 195 4478 188 4390
147 4612 287 5106 98 4419 195 4486 188 4398
147 4613 287 5107 98 4408 195 4481 189 4389
148 4611 287 5111 98 4413 195 4486 188 4395
147 4614 287 5102 98 4410 194 4485 187 4390
146 4606 285 5106 97 4415 193 4479 187 4398
145 4607 285 5107 97 4417 194 4481 188 4395
145 4617 285 5111 97 4420 194 4479 188 4392
145 4612 285 5109 97 4412 193 4479 188 4392
145 4614 284 5107 96 4413 194 4476 189 4391
147 4609 286 5108 98 4421 195 4471 191 4392
147 4613 286 5105 97 4414 195 4478 191 4389
146 4613 286 5110 97 4412 194 4479 190 4392
147 4613 286 5105 97 4407 195 4480 190 4400
147 4609 286 5105 97 4415 195 4479 189 4393
146 4614 286 5102 97 4420 195 4473 191 4391
146 4600 286 5106 97 4418 195 4473 190 4391
146 4618 286 5110 98 4418 195 4474 191 4404
147 4611 286 5106 97 4415 195 4490 190 4397
146 4608 286 5102 97 4416 195 4473 191 4399
James Tursa
2015년 6월 29일
If class(data) returns 'double', what does the phrase "struct with fields that are cell arrays that contain double arrays" mean specifically?
Cory Morales
2015년 6월 29일
Actually, I think it works now. Thanks!
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
