The surf function requires a certain variable format. here is a function that allows you to plot data from a n*3 matrix using the surf function.
to be used for example with a data matrix of the form [time, position, temperature] or [position in x, position in y, concentration]
Help of the function:
surf plot from [x, y, z] data
data is in the form data = [x, y, z]; where x, y, and z are column vectors
This code works for an input dataset were x and y are like the following :
x only contains n values
y only contains m values
x contains m times all the different n values => length(x)=m*n
y contains n times all the different m values => length(y)=n*m
z contains the corresponding z value for each of those (x;y) points
=> length(z) = m*n
Example : (notice that x is either 1,2 or 3, y is 1,2,3 or 4)
data= [1 1 4.5;...
1 2 5 ;...
1 3 6;...
1 4 7;...
2 1 4.6;...
2 2 5.3;...
2 3 6.4;...
2 4 7.1;...
3 1 5;...
3 2 6;...
3 3 7;...
3 4 8];
引用格式
Ambroise (2025). surfPlot(data,varargin) (https://ww2.mathworks.cn/matlabcentral/fileexchange/51097-surfplot-data-varargin), MATLAB Central File Exchange. 检索时间: .
MATLAB 版本兼容性
平台兼容性
Windows macOS Linux类别
标签
致谢
启发作品: sub images
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!