3D plot using time series
16 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ieuan Price-davies
el 27 de Abr. de 2022
Comentada: Star Strider
el 27 de Abr. de 2022
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 comentarios
Respuesta aceptada
Star Strider
el 27 de Abr. de 2022
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 comentarios
Star Strider
el 27 de Abr. de 2022
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!