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

 採用された回答

Cris LaPierre
Cris LaPierre 2022 年 2 月 22 日

1 投票

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 件のコメント

Olga Rakvag
Olga Rakvag 2022 年 2 月 22 日
I see, that was the problem.Thank's a lot!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGraphics Object Properties についてさらに検索

タグ

質問済み:

2022 年 2 月 22 日

編集済み:

2022 年 2 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by