How to plot unequal time series with same x-axis
12 ビュー (過去 30 日間)
古いコメントを表示
Hi everyone,
I required to plot two unequal time series data on one plot with two y-axis. For first times series: x-axis is time dd/mm/yyyy and y-axis a veriable data length is 485 by 2. While, the second time series x-axis is time (dd/mm/yyyy) and y-axis is another varibale (data length: 60 by 2) . I tried but it didn't work:
(dataset also attached for reference)
clear all
clc
T = readtable('data.csv')
R_t=T(:,1);
R_wl=T(:,2);
R_wv=T(:,3);
E_t=T(:,4);
E_m=T(:,5);
plot(R_t,R_wl)
plot(R_t,R_wl,'-o',E_t,E_m,'-x')
0 件のコメント
採用された回答
Simon Chan
2022 年 1 月 16 日
You may try the following:
T = readtable('data.csv'); % Read csv file as entire table
TT2 = table2timetable(T(:,4:5)); % Extract the 4th and 5th columns as TT2
TT1 = table2timetable(T(:,1:3)); % Convert 1st to 3rd column to TT1
TT3 = outerjoin(TT1,TT2); % Perform outerjoin
%
yyaxis left
plot(TT3.Var1,TT3.Var2,'c--'); % Plot data from Column 2 of csv file
yyaxis right
plot(TT3.Var1,TT3.Var5,'b+') % Plot data from Column 5 of the csv file
0 件のコメント
その他の回答 (1 件)
Seth Furman
2022 年 9 月 23 日
Plotting multirate data is now easier with stackedplot, which now supports multiple timetable inputs.
T = readtable("https://in.mathworks.com/matlabcentral/answers/uploaded_files/864145/data.csv")
TT1 = table2timetable(T(:,1:3))
TT2 = table2timetable(T(:,4:5))
sp = stackedplot(TT1,TT2);
0 件のコメント
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!