Unwanted line in on plot
1 回表示 (過去 30 日間)
古いコメントを表示
I have two arrays about x-axis and y-axis and plot(x,y) shows following graph.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/169949/image.jpeg)
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/169951/image.jpeg)
How can I change second plot to original plot with combined array?
0 件のコメント
採用された回答
Walter Roberson
2017 年 11 月 21 日
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 件のコメント
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.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!