How to combine 4 different vectors with time durations into one smooth time vector?
3 views (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
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]
% Get the cumulative sum going down rows within each column.
c = cumsum(m, 1)
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!