Filter löschen
Filter löschen

Matlab Plotting Problem: Plotting two vectors in which the entries in one vector are not sequential

1 Ansicht (letzte 30 Tage)
Hello,
I am using the plot(x,y) for the following:
time = [16;17;18;19;20;21;22;23;0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15]
y = [value1; value2;...]
When I plot(time,y) I get the following graph: http://imageshack.us/photo/my-images/707/jo9f.jpg/
Does anyone know why that diagonal line is created connecting the x values of the points (23,y) and (0,23) when Matlab plots (23,y) and then (0,y1)?
Why is it that Matlab can only plot sequentially, and is there a way around this?
Thanks!
Andrew

Akzeptierte Antwort

the cyclist
the cyclist am 1 Sep. 2013
[sortedTime sortingIndex] = sort(time);
sortedY = y(sortingIndex);
plot(sortedTime,sortedY)

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by