Filter löschen
Filter löschen

Unwanted line in on plot

7 Ansichten (letzte 30 Tage)
Gyeongtae
Gyeongtae am 21 Nov. 2017
Kommentiert: Gyeongtae am 21 Nov. 2017
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?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 21 Nov. 2017
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 Kommentare
Walter Roberson
Walter Roberson am 21 Nov. 2017
Bearbeitet: Walter Roberson am 21 Nov. 2017
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 am 21 Nov. 2017
Yes. You're right. The linear-like graph is come from second column. I understand! Thank you Walter :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2차원 플롯과 3차원 플롯 finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!