3D plot using time series
조회 수: 13 (최근 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!




