How to plot 3D? Surf or Plot3?
조회 수: 7 (최근 30일)
이전 댓글 표시
Hello,
Imagine I have a function A(x,y,t).
But the dimensions of y and t are different with that of x (and so A). What I mean is that for example there are values of A(x) for 5 different values of y and 8 different values of t.
Of course, I can plot A vs. x in 2D plot for different values of t for example. But what I want is that can I plot them for different values of y at the same plot as well? how?
How can I plot them all in one plot? Should I use plot3 or Surf?
I tried both including meshgrid, but that doesn't work.
Thanks so much in advance.
Steven
댓글 수: 0
채택된 답변
Walter Roberson
2015년 5월 4일
You have not given enough information about what you want the resulting plot to look like.
Effectively after running the function you have an output array B which is length(x) by length(y) by length(t), and you want to plot that 3D array. Plotting a 3D array requires 4 dimensions of output -- x, y, z, and value. surf() is for 3 dimensions only, x, y, value.
You can code the additional dimension as colour, shape of a marker, size of a marker, or (as a hint rather than directly) as transparency. Or you can slice() the data or you can create isosurfaces. scatter3() can be pretty useful. Transparency can be useful for voxel rendering. Another possibility is to represent the additional dimension through time (an animation.)
I suspect that you were thinking of something similar to a waterfall plot in which an additional dimension of data is represented through a regular displacement in space. Waterfall plots themselves really only have three dimensions though, such as (x, value, time). You can use the spacial displacement technique with surf() plots, making a stack of hills; if you are thinking about that approach keep in mind the difficulty that the user would have in attempting to clearly examine the values in the "lower" stacks.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!