Plot matrices in area graph of unequal length (i.e. size of rows)
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Konstantinos Tsitsilonis
il 5 Gen 2019
Commentato: Star Strider
il 5 Gen 2019
Hi all,
I am having two matrices, the one is 50x2 and the other is 20x2. The first columns of both are dates, and the second colums are payments per each date. I would simply like to display the data in an area graph where the 50x2 matrix would be on the botom (i.e. the red), and the 20x2 matrix would be on the top (i.e. the yellow). Obviously the sum of both vectors would be the total height of the graph.
However to peform such a task, as I perceive it, I would have to make the two vectors compatible dimensionwise (i.e. have the same number of rows).
My thinking is to try to 'reshape' the matrices such as any idetical numbers on the first colum become removed, and numbers of the second column that remain, are stacked as more colums, with the gaps filled by either zero on nan.
Here is an example, 'cause it can be hard to understand:
X_init = [7.3743 0.0383 ;
7.3743 0.0379;
7.3743 0.0377;
7.3743 0.0378;
7.3743 0.0374;
7.3743 0.0273;
7.3742 0.0272;
7.3742 0.0272;
7.3742 0.0270;
7.3742 0.0270] ; % Initial matrix
X_resh = [7.3743 0.0383 0.0379 0.0377 0.0378 0.0374 0.0273 ;
7.3742 0.0272 0.0270 0.0270 NaN NaN NaN] ; % Reshaped Matrix
Thus far I am not certain that the above might lead to the desired result.
Thanks for your help in advance
KR,
KMT.
0 Commenti
Risposta accettata
Star Strider
il 5 Gen 2019
The only approach I can suggest is to interpolate one or both data sets to a common set of dates. This is best done using the retime (link) function. This first requires that you create your data as a timetable (see the documentation section on Create Timetables (link) to understand how to do that).
2 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Line Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!