# Plotting a surface from a timetable

4 visualizzazioni (ultimi 30 giorni)
Paul il 16 Feb 2024
Commentato: Paul il 16 Feb 2024
I've developed a timetable (attached), and I want to make a surface plot from it. I want "Start Time" and "Distance [km]" to be my x and y axes, with "Flow Rate [veh/hr]" as the corresponding output on the z axis. I've tried using plot3, but I'm getting a jumbled mess instead of a smooth surface.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Voss il 16 Feb 2024
Here's one way:
X = Lane1Data.("Start Time");
Y = Lane1Data.("Distance [km]");
Z = Lane1Data.("Flow Rate [veh/hr]");
I = scatteredInterpolant(hours(X-min(X)),Y,Z);
X_plot = linspace(min(X),max(X),50);
Y_plot = linspace(min(Y),max(Y),50);
[XX,YY] = meshgrid(hours(X_plot-min(X_plot)),Y_plot);
Z_plot = I(XX,YY);
surf(X_plot,Y_plot,Z_plot)
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Paul il 16 Feb 2024
Awesome, thanks a lot!

Accedi per commentare.

### Più risposte (1)

Fangjun Jiang il 16 Feb 2024
Modificato: Fangjun Jiang il 16 Feb 2024
when you use plot() or plot3(), the plot connects the data points from the first to the second, till the last. Sometimes this causes bad visual effect.
What you need might be scatter3(), or use plot3(x,y,z,'.') which means just show the data points but not to connect the data points.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Surface and Mesh Plots in Help Center e File Exchange

R2023b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by