MATLAB: Cubic Spline Interpolation of a 3D surface Plot with Datetick Axis Labels

3dcubicdatetickMATLABspline interpolationsurface plot

I am attempting to make a 3D surface plot of some numbers that need to have cubic spline interpolation applied to them.
The problem with this is that after doing so I need to label the x axis with a datetick format, not epoch time. Whenever I try to do this, the datetick just defaults to January 1 00:00:00. I was hoping someone could help me with this. An example of my code is below:
simulatedTime = [34630:34929, 34630:34929];
simulatedZ = 350 + 250*rand(600, 1);
simulatedY = [sort(floor(50+10*rand(300, 1))); sort(floor(100+10*rand(300, 1)))];
[xq, yq] = meshgrid(min(simulatedTime):60:max(simulatedTime),...
min(simulatedY):1:max(simulatedY));
zq = griddata(simulatedTime, simulatedY, simulatedZ, xq, yq, 'cubic');
figure;
surf(xq, yq, zq);
xData = datetime(34630:34929, 'convertfrom','posixtime');
datetick('x','HH:MM:SS');
Thank you.

Best Answer

See if this works in your application:
simulatedTime = [34630:34929, 34630:34929];
simulatedZ = 350 + 250*rand(600, 1);
simulatedY = [sort(floor(50+10*rand(300, 1))); sort(floor(100+10*rand(300, 1)))];
[xq, yq] = meshgrid(min(simulatedTime):60:max(simulatedTime),...
min(simulatedY):1:max(simulatedY));
zq = griddata(simulatedTime, simulatedY, simulatedZ, xq, yq, 'cubic');
figure;
surf(xq, yq, zq);
Ax = gca;
xData = cellstr(datetime(34630:34929, 'convertfrom','posixtime'));
Ax.XTickLabel = xData;
It creates a cell array with the cellstr function, then assigns those to the 'XTickLabel' object.
Experiment with it to get the result you want.