How to work with Unix timestamps in Matlab?

How about date = datestr(unix_time/86400 + datenum(1970,1,1)) if unix_time is given in seconds, unix_time/86400 will give the number of days since Jan. 1st 1970. Add to that the offset used by Matlab’s datenum (datenum(0000,1,1) == 1), and you have the amount of days since Jan. 1st, 0000. This can be easily converted to human-readable form … Read more

3D curvefitting

To fit a curve onto a set of points, we can use ordinary least-squares regression. There is a solution page by MathWorks describing the process. As an example, let’s start with some random data: % some 3d points data = mvnrnd([0 0 0], [1 -0.5 0.8; -0.5 1.1 0; 0.8 0 1], 50); As @BasSwinckels … Read more

MATLAB linked list

MATLAB has access to Java: >> a=java.util.LinkedList; >> li=a.listIterator; >> li.add(2); >> li.add(int8(77)); >> li.add(77); >> li.add(boolean(true)); >> li.add(‘Mr. Bill’); >> li.previous(); >> li.add([1 2 3 4 5]); >> a a = [2.0, 77, 77.0, true, [D@66a917, Mr. Bill] >> a.get(4) ans = 1 2 3 4 5 The one downside of this approach is … Read more