MATLAB Answers

Is there a way to add synchronize function to Matlab 2016a?

16 views (last 30 days)
M.Abuasbeh on 10 Jan 2020
Edited: Adam Danz on 16 Jan 2020
I have two tables thet contain 2 columns each (time stamp & measured value). I would like to synchronize them both into one table that has 3 columns (time stamp & measured value1, measured value2) and have NaN value in the rows where either of measured value1 or measured value2 is missing for that time step.
I found the function synchronize ( which seems to be perfect for the job but I have Matlab 2016a and it says that "Undefined function 'synchronize' for input arguments of type 'table'.".
Is there a way to added this function to Matlab 2016a or is there another way to perform this functionality in Matlab 2016a?

  1 Comment

Adam Danz
Adam Danz on 10 Jan 2020
As you can see at the bottom of that page, that function was released in r2016b and cannot be imported in earlier releases. You'll have to write your own function or search for a pre-existing function. If your timetables have unique timestamps it could be as easy as vertically concatenating the tables and sorting the rows by the time column.

Sign in to comment.

Accepted Answer

Steven Lord
Steven Lord on 10 Jan 2020
As Adam Danz said, this function was released in release R2016b. It also only works on timetable arrays, not table arrays, as you can see from the description of the TT1 and TT2 input arguments. Compare this to a function like innerjoin, whose Tleft and Tright inputs can be either table or timetable arrays.
While you could theoretically write your own synchronize function like Adam suggested, a much easier alternative would be to upgrade to release R2016b or later if possible and then store your time-based data as a timetable (the timetable function was introduced in R2016b.)


Show 1 older comment
Steven Lord
Steven Lord on 10 Jan 2020
I would expect most code written with release R2016a to work in release R2016b. Exceptions would be if you wrote the code using functionality that had a backwards incompatible change in that release, most or all of which should be listed in the Release Notes (that's the Release Notes for MATLAB, if you're using other products you could review their Release Notes as well.)
That could include trying to do something that didn't work in the older release but now does work, like implicit expansion (which is listed as having a compatibility consideration in those Release Notes.)
[1 2] + [1; 2] % Fails in older releases, works in R2016b and later
M.Abuasbeh on 15 Jan 2020
Thanks Steven!!
I thnik it would be a good idea to install R2016b.
Also I am wonding, is it a good idea to install both 2016b as well as the most recent version (for example R2019b)?
So I can write new code in the new vesion and have access to all the new functionalities.
Adam Danz
Adam Danz on 16 Jan 2020
If the users of your program(s) have access to the most recent release of matlab, I see no reason not to use the most recent release.
On the other hand, if you know that users are currently using an old release of Matlab and have no plans to update, you should either
  1. write the program in the latest possible release that your users have access to.
  2. write the program in the most recent release and carefully select functions & features that are backwards compatible.
The problem occurs when code written in a newer release uses a function or a feature that was recently introduced and then that program is run on an earlier release that doesn't have access to the function or feature.
For example, you can see when tiledlayout was introduced by scrolling to the bottom of the function's documentation. If this function is run on a release prior to r2019b, it will cuase an unfamiliar function or variable error.
Lastly, at a more advanced level, you can detect the version number of the instance of Matlab running the code and use a conditional statement to handle actions taken for nearer and later releases. Demo:
% Return the matlab release number
vStrct = ver('Matlab');
vs = str2double(vStrct.Version);
% Detect if Matlab version is prior to r2016b
if vs < 9.1 || isnan(vs)
% Do something
% Do something

Sign in to comment.

More Answers (0)

Sign in to answer this question.