필터 지우기
필터 지우기

How can I resolve index exceeding error while I plot something?

조회 수: 1 (최근 30일)
Jinah Lee
Jinah Lee 2017년 3월 25일
댓글: Jinah Lee 2017년 3월 25일
Hello all, I'm keep having error when I tried to put title on my plot. The error message said "Index exceeds matrix dimensions." Here's my code, so please let me know why I got this message. Thanks!
figure
title('2')
h = plot(dataCenter(:,1),dataCenter(:,2),'Color','b')
  댓글 수: 2
kowshik Thopalli
kowshik Thopalli 2017년 3월 25일
Can you tell us about the dimensions of dataCenter? or upload it ? and for the title to be added to the graph, please use the command after the plot command
Jinah Lee
Jinah Lee 2017년 3월 25일
Thanks kowshik Thopalli!! dataCenter is 10*2 matrix.
dataCenter =
0 0.0200
10.0000 0.0300
20.0000 0.0350
30.0000 0.0700
40.0000 0.0900
50.0000 0.0950
60.0000 0.0950
70.0000 0.1000
80.0000 0.0950
90.0000 0.1000

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

채택된 답변

Jan
Jan 2017년 3월 25일
The error message is clear: An indexing operation in this line exceeds the defined array sizes:
h = plot(dataCenter(:,1),dataCenter(:,2),'Color','b')
Either dataCenter has 1 column only, or you have redefined plot by an array and the inputs are interpreted as indices. You can check both by using the debugger. Type this in the command window:
dbstop if error
Now run the code again until it stops at the problem. Now examine, what's going on:
size(dataCenter)
which plot -all

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by