3D plot using time series
14 次查看(过去 30 天)
显示 更早的评论
I'm trying to create a 3D graph like the image below. I have attached a reduced data set of my results below. Does anyone know how this would work? 

I've currently tried surf and waterfall but I can't seem to get it working. It a mess but this is kind of what I've been working with
results.
In effect I want each day of the results to be shown on a different "slice"
%Sets Date time format for when table is read
opts = detectImportOptions("results.xlsx","Sheet","Sheet1");
opts = setvartype(opts,"Date","datetime");
opts = setvaropts(opts,"Date",'InputFormat','dd.MM. HH:mm');
results = readtable("results.xlsx",opts);
x = results.Efficiency;
y = results.Power;
% z = results.Date; % HOW DO YOU INCLUDE THIS?
[X,Y] = meshgrid(x,y);
Z = peaks(X,Y);
waterfall(X,Y,Z)
0 个评论
采纳的回答
Star Strider
2022-4-27
results = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/980365/results.xlsx', 'VariableNamingRule','preserve');
results.Date = datetime(results.Date, 'InputFormat','MM.dd. HH:mm', 'Format','MM.dd. HH:mm')
x = results.Efficiency;
y = results.Power;
z = results.AmbientTemp;
xv = linspace(min(x), max(x), numel(x)); % Create Vector For Interpolation
yv = linspace(min(y), max(y), numel(y)); % Create Vector For Interpolation
[X,Y] = ndgrid(xv,yv); % Create Matrices For Interpolation
Z = griddata(x, y, z, X, Y); % Interpolate Matrix
figure
stem3(x, y, z, 'p', 'filled')
grid on
title('Stem Plot')
figure
surfc(X, Y, Z)
grid on
xlabel('Efficiency')
ylabel('Power')
zlabel('Temperature [°C]')
title('Surface Plot')
Experiment with this approach with your actual data.
.
4 个评论
Star Strider
2022-4-27
As always, my pleasure!
To create different surface plots, change the ‘x’ and ‘y’ variables in my code to be the independent variables for the plot, and then use the appropriate ‘z’ vector in the griddata call. The code should be relatively robust to those changes.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!