Cubic Spline Interpolation of a 3D surface Plot with Datetick Axis Labels
4 views (last 30 days)
Show older comments
Logan Suarez Parmer
on 2 Feb 2019
Edited: Logan Suarez Parmer
on 6 Feb 2019
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.
0 Comments
Accepted Answer
Star Strider
on 2 Feb 2019
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.
2 Comments
More Answers (0)
See Also
Categories
Find more on Spline Postprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!