3D Plot - term structure
1 次查看(过去 30 天)
显示 更早的评论
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149546/image.png)
Hi there,
I am trying to do a figure similar to the one attached.
I have exactly a (224x1) vector with dates (x-axis), a (10x1) vector with maturities (y-axis) and a (224x10) matrix with the values (z-axis).
How can I combine this to make a plot like the one attached?
Thanks, V
0 个评论
采纳的回答
pfb
2015-4-27
That is a mesh plot.
% here I'm making up data with the same sizes as yours
dates = 1:224;
maturities = (1:10)';
values=rand(224,10);
% here I'm plotting the mesh plot. Of course you'll use your data
mesh(maturities,dates,values);
% if you need to swap the axes then go
mesh(dates,maturities,values');
You can consider using the surf function instead of mesh. Another option is waterfall. Type "help mesh" (and in general "help function") to get the documentation.
2 个评论
pfb
2015-4-27
oh, I forget the axes labels. You get those as follows
xlabel('maturities');
ylabel('dates');
zlabel('values');
Of course you have to set xlabel and ylabel according to the order you chose.
Youssef Khmou
2015-4-27
编辑:Youssef Khmou
2015-4-27
the third option is using surfc function which is the same as surf plus a contour plot in the z=0 plane.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!