Guru's needed - 3-D plotting
4 views (last 30 days)
Show older comments
Hi, I am new to Matlab and am trying to do a 3-D plot of an optimization report that I use to analyze trading strategies. The optimization report will have several things that I would want to plot but essentially I would like to plot Parameter1 on the X axis, Parameter2 on the Y axis and the corresponding net profit from parameter1 and parameter2 on the Z axis.
I have the optimization report in Excel in the format shown below. Whenever I attempt to choose 3 columns and make that a variable to plot, it seems to be leaving out a parameter value and plotting the test number (ie test 1, test 2 etc). This obviously distorts the 3-D graph making it meaningless. Has anyone ever run into this problem and if so, can you give me some insights into the correct way to assign the data to the correct axis? Many Thanks!
I will attach a screenshot of my spreadsheet.
4 Comments
Image Analyst
on 5 Sep 2014
Right, because all I see are parameter values, not test numbers . I don't see at all the "test number (ie test 1, test 2 etc)" that you referred to, leading me to think there are columns or cells left out of your screen capture. Make it EASY for us to help you, not hard! Think along the lines of "What do I need to provide these people for them to reproduce my problem and fix it" http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
Accepted Answer
Roger Stafford
on 5 Sep 2014
Normally plotting of 3D surfaces is done using 'surf' but it requires a grid-type array arrangement of the parameters, which you don't have. You can get a kind of plot using 'plot3' by not connecting individual points with lines but using only dots, asterisks, or tiny o's.
Suppose you have all the values in column A in a vector P1, those in column B in vector P2, and those in column D in vector N. Then do this:
plot3(P1,P2,N,'y*')
This will print yellow asterisks at each point in 3D for the "surface" which is composed of the data points you have. The x and y axes of the points correspond to the two parameters and the z axis gives the profit.
Normally 'plot3' is used for plotting 3D curves, so the above plot will not be an ideal display. Ideally you would use the parameter data you have to interpolate/extrapolate over to a mesh arrangement of points P1 amd P2 with interpolated N values and then you could use 'surf'. However the low number of data points you have makes this look rather impractical.
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!