3D plot using time series
16 ビュー (過去 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!