How to plot several curves on the same figure plot with the same StartTime

3 ビュー (過去 30 日間)
S.M
S.M 2019 年 6 月 25 日
コメント済み: S.M 2019 年 6 月 26 日
Hi guys,
again a small problem. I would like to plot several curves in one figure, but beecause it's a time series, I get a plot where the curves are behind each other.
I saw in one tutrial, that it's possible to set the StartTime to zero for both curves, but I can't find it anymore. Could you please help me?
% Read tables
C1 = readtable('Curve1.xlsx');
C2 = readtable('Curve2.xlsx');
% Convert to timetable
TTC1 = table2timetable(C1);
TTC2 = table2timetable(C2);
% Interpolate
dt = milliseconds(100);
IC1 = retime(TTC1,'regular','linear','TimeStep', dt);
IC2 = retime(TTC2,'regular','linear','TimeStep', dt);
% Plot
plot(IC1.Time, IC1.Volt);
hold on;
plot(IC2.Time, IC2.Volt);
Thanks a lot.

採用された回答

Jan
Jan 2019 年 6 月 25 日
  2 件のコメント
S.M
S.M 2019 年 6 月 25 日
編集済み: S.M 2019 年 6 月 25 日
I don't know if this is it, but I want to plot the curves without date and hours. Both curves should start from 0 seconds, so that he curves lie one above the other, not like now behind each other.
Later the code should be able to plot 10 curves or more.
S.M
S.M 2019 年 6 月 26 日
It worked, thank you Jan!

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

その他の回答 (1 件)

S.M
S.M 2019 年 6 月 26 日
I don't know if there is a better solution or not, but I solved it with:
% Read tables
C1 = readtable('Curve1.xlsx');
C2 = readtable('Curve2.xlsx');
% Convert to timetable
TTC1 = table2timetable(C1);
TTC2 = table2timetable(C2);
% Interpolate
dt = milliseconds(100);
IC1 = retime(TTC1,'regular','linear','TimeStep', dt);
IC2 = retime(TTC2,'regular','linear','TimeStep', dt);
% Set StartTime
StartTime = datetime('13.06.2019 00:00.000', 'InputFormat', 'dd.MM.yyyy mm:ss.SSS');
IC1.Properties.StartTime = StartTime;
IC2.Properties.StartTime = StartTime;
% Plot
plot(IC1.Time, IC1.Volt);
hold on;
plot(IC2.Time, IC2.Volt);
and as result I get this:
Curveontop.jpg

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by