Plot 4d surface from x, y, z, c data

조회 수: 224(최근 30일)
Carol
Carol 2013년 11월 1일
댓글: Cosmin Constantin Popescu 2019년 1월 22일
Hello,
I was wondering how to plot a 4d surface. I have x, y and z data (unevenly spaced), and c data (c is a function of x, y, z). I would like to plot c as a surface, with particular value of c being defined by a colour.
My x, y, z and c data are column vectors, but I don't think this is suitable for the surf(x, y, z, c) function.
Any help would be greatly appreciated.
Carol

채택된 답변

Doug Hull
Doug Hull 2013년 11월 1일
I am not sure, but I think you might want sliceomatic

추가 답변(2개)

Simon Fluegge
Simon Fluegge 2017년 2월 12일
편집: Walter Roberson 2017년 2월 12일
I have the following data:
x=rand(1,5)
y=rand(1,10)
z=rand(1,13)
score=f(x,y,z)
I would like to plot a surface. The color of the surface is related to the score value. To each data pair of x and y I only want to plot the related z value which has the best score value.
  댓글 수: 2
Cosmin Constantin Popescu
Cosmin Constantin Popescu 2019년 1월 22일
Thank you for the idea with the isosurface. It's exactly what I needed. For anyone interested, isosurface can be used with non-evenly spaced x,y,z coordinates.

댓글을 달려면 로그인하십시오.


Ryan
Ryan 2014년 8월 5일
If you want to plot a surface, you should be able to rearrange your z and c data into matrices so that they form a matrix, which would then make it suitable for the surf(x,y,z,c) function.
Example:
x = 1:10;
y = 11:20;
z = x'*y;
c = randi(10,10);
surf(x,y,z,c)
Column vectors would work well for using scatter3(x,y,z,s,c) (just use scalar s, e.g. 10) and this might be a good way to quickly visualize the data. The problem with having z as a column vector for a surface is Matlab doesn't know how they're supposed to line up, and which vertices to connect to form a continuous surface. You give it this information by passing z in as a rectangular matrix, and x and y as vectors with elements that define the lines on the surface in their respective domains.
Let us know whether your data can be shaped to fit this.
  댓글 수: 4
Walter Roberson
Walter Roberson 2016년 4월 25일
If the inputs x and y are both column vectors then use
z = x * y.';

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by