How to combine 4 different vectors with time durations into one smooth time vector?

3 views (last 30 days)
I have four different 1x1440 vectors with time durations. I need to combine them in order to make one smooth time vector so I can plot data. For example:
ta= [0.05 0.09 0.18 0.45]
tb= [0.005 0.0001 0.10 0.02]
tc= [0.54 0.23 0.12 0.65]
td= [0.001 0.002 0.003 0.004]
I would like the time vector to be something like:
time = [ta(1), ta(1)+tb(1), ta(1)+tb(1)+tc(1)....ta(1)+tb(1)+tc(1)+td(1)+ta(2)....]
Or any other advice because each time block has a value. ta(1) and tb(1) have corresponding values, so from time 0_ta I will plot Value_ta(1), then from ta_tb I will plot Value_tb(1) and so on. If there is a better to approach this please let me know. Everything is a 1x1440 double.
Thanks!

Answers (1)

Image Analyst
Image Analyst on 3 Dec 2021
Do you have the x (t) values, or just the y signal values as a function of index?
Do you mean this:
ta= [0.05 0.09 0.18 0.45];
tb= [0.005 0.0001 0.10 0.02];
tc= [0.54 0.23 0.12 0.65];
td= [0.001 0.002 0.003 0.004];
% Stack together into a matrix.
m = [ta;tb;tc;td]
m = 4×4
0.0500 0.0900 0.1800 0.4500 0.0050 0.0001 0.1000 0.0200 0.5400 0.2300 0.1200 0.6500 0.0010 0.0020 0.0030 0.0040
% Get the cumulative sum going down rows within each column.
c = cumsum(m, 1)
c = 4×4
0.0500 0.0900 0.1800 0.4500 0.0550 0.0901 0.2800 0.4700 0.5950 0.3201 0.4000 1.1200 0.5960 0.3221 0.4030 1.1240

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!