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')

 Réponse acceptée

Cris LaPierre
Cris LaPierre le 22 Fév 2022

1 vote

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 commentaire

Olga Rakvag
Olga Rakvag le 22 Fév 2022
I see, that was the problem.Thank's a lot!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Properties dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by