Remove line between first and last point on plot

16 visualizaciones (últimos 30 días)
manateejoe
manateejoe el 14 de Jul. de 2015
Respondida: manateejoe el 14 de Jul. de 2015
I am plotting data from a text file, however, the plot automatically connects the first and last points. How do I get rid of this line?
data = load('data.txt');
time = data(:,1);
avg = data(:,2);
plot(time, avg)

Respuesta aceptada

manateejoe
manateejoe el 14 de Jul. de 2015
I was able to figure it out: I had to sort my data:
[time, dum] = sort(time);
avg = avg(dum);

Más respuestas (1)

Honglei Chen
Honglei Chen el 14 de Jul. de 2015
Are you sure your last point and first point are not the same? If they are, simply do
plot(time(1:end-1),avg(1:end-1))
  2 comentarios
manateejoe
manateejoe el 14 de Jul. de 2015
No, they are different: first point: 371.447, last point: 380.805. With this method, I still get the line in between
Star Strider
Star Strider el 14 de Jul. de 2015
See if:
time = [data(:,1); NaN];
avg = [data(:,2); NaN];
improves the plot.
If your data.txt file is not too large, attach it (use the ‘paperclip’ icon). Without it, it is only a guess as to what the best solution is.

Iniciar sesión para comentar.

Categorías

Más información sobre Annotations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by