![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/864175/image.png)
How to plot unequal time series with same x-axis
15 次查看(过去 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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/864175/image.png)
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!