Tying to plot from .txt file and get extras lines if I use x vector.
data = readtable(fileName, 'HeaderLines',23); data.Properties.VariableNames = {'time', 'Bolgehoyde', 'Last'};
f1 = figure(1)
subplot(3,1,1); plot(data.time, data.Bolgehoyde, 'r')

 Respuesta aceptada

Cris LaPierre
Cris LaPierre el 22 de Feb. de 2022
It appears your time restarts every 20000 rows. The horizontal lines, then are when the time jumps from ~10 back to ~0.
You could sort your data based on time, but I don't think you want to do that. I think it would be better to plot each set of 20000 rows separately.
fileName = 'f1_3_A2_forsok.txt';
data = readtable(fileName, 'HeaderLines',23);
data.Properties.VariableNames = {'time', 'Bolgehoyde', 'Last'};
% Identify where time restarts. Use that to identify each time series
tseries = diff(data.time)<0;
data.Group = cumsum([0; tseries]);
fsize = 12;
fsize2 = 10;
for s = 0:data.Group(end)
subplot(3,1,s+1)
yyaxis right
plot(data.time(data.Group==s), data.Bolgehoyde(data.Group==s), 'r')
ylabel('Overflatehevning [m]','FontSize',fsize)
set(gca,'ycolor','k')
yyaxis left
plot(data.time(data.Group==s), data.Last(data.Group==s),'b')
xlim([0 10])
end

1 comentario

Olga Rakvag
Olga Rakvag el 22 de Feb. de 2022
I see, that was the problem.Thank's a lot!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Object Properties en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 22 de Feb. de 2022

Editada:

el 23 de Feb. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by