How can i get the surface plot of 3 variables

41 ビュー (過去 30 日間)
obinna
obinna 2013 年 10 月 16 日
コメント済み: Stephen23 2017 年 4 月 3 日
i am having a problem getting a 3D plot of 3 variables i am working with. An example of my code and problem is thus:
%the x,y and z matrices below a composed of variables gotten from an experiment
x=a 100 by 1 matrix
Y=a 100 by 1 matrix
z=a 100 by 1 matrix
i want to plot x and y against z; to see the value of z for a corresponding x,y value.
this plot is to be a surface plot. i have read about the mesh and surf function but dont understand how this would be applied here because i have 3 different x,y,z values. I would be glad if a code for this is given to me based on the the x,y,z variables above thanks.

回答 (2 件)

Jonathan LeSage
Jonathan LeSage 2013 年 10 月 16 日
You could use the plot3 command to visualize the data that you have as a single line in 3d space.
To use the surf or mesh functions, you would need a matrix of Z data (in your case, a 100x100 matrix) to correspond to the x and y data vectors. If you need to visualize the data as a surface plot, you will need to replicate the z data vector so you have a 100x100 matrix.
repeatedZ = repmat(z,1,100)
surf(x,y,repeatedZ)
Hope this helps!
  1 件のコメント
Sean de Wolski
Sean de Wolski 2013 年 10 月 16 日
Or interpolate it on to a grid,
doc scatteredInterpolant
doc griddata

サインインしてコメントする。


Koyel Sen
Koyel Sen 2017 年 4 月 3 日
Hi all,
I am new to MATLAB .I have been assigned to plot surface graph using X,Y,Z and corresponding concentration values.Can anyone help me with that.I have tried but everywhere it is written in order to plot surf I have to have relationship between Z, and X,Y.which I don't have .All of my values are in 1 by n matrix.I would really appreciate if someone can help me out with it.
  1 件のコメント
Stephen23
Stephen23 2017 年 4 月 3 日
@Koyel Sen: ask a new question, and upload some sample data for us to look at.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by