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

 Accepted Answer

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 Comment

I see, that was the problem.Thank's a lot!

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!