Hello, How can I plot a figure as below? (3d)

its Pressure amplitude(size 1x32001) against time(size 1x32001) in 6 different location, I have 6 arrays of pressure (6 different places) and time array (same for all 6)

 Akzeptierte Antwort

Star Strider
Star Strider am 20 Jul. 2018

1 Stimme

I am not certain what you want or what your data actually are.
Try this (with your data, not my created data):
N = 25;
time = linspace(0, 1, N); % Row Vector - Created Data
location = linspace(0, 36, 6);
pressure1 = sin(2*pi*time*N + rand); % Row Vector - Created Data
pressure2 = sin(2*pi*time*N + rand);
pressure3 = sin(2*pi*time*N + rand);
pressure4 = sin(2*pi*time*N + rand);
pressure5 = sin(2*pi*time*N + rand);
pressure6 = sin(2*pi*time*N + rand); % Row Vector - Created Data
pressure = cat(1, pressure1, pressure2, pressure3, pressure4, pressure5, pressure6);
figure
surf(time, location, pressure)
grid on
xlabel('t (s)')
ylabel('x (cm)')
zlabel('P (kPa)')
colorbar(gca, 'westoutside')
This approach concatenates your pressure data vectors to create the matrix the surf function needs for the third argument. You can use vectors for the x and y coordinates.

2 Kommentare

Shima Abdullateef
Shima Abdullateef am 23 Jul. 2018
Thank you so much for your help...so it becomes like the attached image. Because of the number of the points (32001), it becomes completely black. Is there any way that I can solve that?
many thanks,
With a dense plot, the colours of the patch edges become dominant. The easiest way to deal with that is to turn off the 'EdgeColor' property.
Example
figure
hs = surf(rand(500));
set(hs, 'EdgeColor','none')
grid on
See the documentation on Surface Properties (link) for details on this and other properties you can tweak.
Another option is to interpolate the colours.
Example
figure
surf(rand(500))
shading(gca, 'interp')
grid on
See the documentation on the shading (link) function for details.
The plots these produce are slightly different. Experiment to get the result you want.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Color and Styling finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by