How to Generate 3d Plot from 2 2d graphs?
24 views (last 30 days)
Show older comments
Hello everyone
I would like to generate a 3d mesh plot from two 2d graphs.
- first 2d graph:
x1 = normalized time, y1 = normalized resistance
- second 2d graph:
x2 = normalized time, y2 = normalized stress
first and second 2d graphs would be the side of the 3d mesh.
top view of the 3d plot would be plot of y1 and y2
the final result would be the crossing of the two 2d graphs
0 Comments
Answers (1)
Nathan Hardenberg
on 22 May 2023
To plot a 3D-Surface/mesh you need a function that is dependent on two variables (https://de.mathworks.com/help/matlab/ref/meshgrid.html). Normally the result is then plotted on the z-axis. Your two functions seem to only have the time as an input. Plotting this as a surface would not work (or at least would not make sense).
If you have a function with two variables, check the link of the Matlab documentation I provided.
The following code shows how you could do something like you discribe, but without a mesh/surface. Note that the z-axis now shows values for y1 and y2.
x = linspace(0,10,10);
y1 = rand(1,10);
y2 = rand(1,10);
zerosVec = zeros(1,10);
figure(1); hold on; grid on;
plot3(x, zerosVec, y2)
plot3(zerosVec, x, y1)
xlabel('x')
ylabel('x')
zlabel('y1 or y2')
view([-25.10 33.53])
0 Comments
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!