I have two arrays about x-axis and y-axis and plot(x,y) shows following graph.
After I combine two arrays into one by doing data=[x,y], plot(data) has strange brown diagonal line. X,Y axis is also changed.
How can I change second plot to original plot with combined array?

 채택된 답변

Walter Roberson
Walter Roberson 2017년 11월 21일

0 개 추천

When you plot() an array that has two columns, that does not mean that the first column should be used for x and that the second column should be used for y. Instead what it means is the same as
plot(1:size(data,2), data(:,1), 1:size(data,2), data(:,2))
That is, each column is used as y coordinates the the x coordinate is the row number. One line is plotted per column.

댓글 수: 3

Gyeongtae
Gyeongtae 2017년 11월 21일
thank you. I thought first column of array should be x and second column be y. Then could you what causes the unwanted brown line on plot?
Walter Roberson
Walter Roberson 2017년 11월 21일
편집: Walter Roberson 2017년 11월 21일
MATLAB automatically uses the next available colors when you plot multiple lines. It looks to me as if that line corresponds to your second column of data.
Gyeongtae
Gyeongtae 2017년 11월 21일
Yes. You're right. The linear-like graph is come from second column. I understand! Thank you Walter :)

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 2차원 플롯과 3차원 플롯에 대해 자세히 알아보기

태그

질문:

2017년 11월 21일

댓글:

2017년 11월 21일

Community Treasure Hunt

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

Start Hunting!