How to plot unequal time series with same x-axis
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Simon Chan
il 16 Gen 2022
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 Commenti
Più risposte (1)
Seth Furman
il 23 Set 2022
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 Commenti
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!