Guru's needed - 3-D plotting

4 views (last 30 days)
Jeremy
Jeremy on 5 Sep 2014
Commented: Jeremy on 9 Sep 2014
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
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
Jeremy
Jeremy on 7 Sep 2014
HI, thanks for your insights. Each row in the optimization reports corresponds to a test number in ascending order. I have updated the spreadsheet to show the test numbers. I hope this helps. I have watched a couple of the videos on 3-d plotting and it looked like they were just grabbing 3 columns of data via the import, making them a variable and plotting them easily. I really do appreciate everyone's inputs. Hopefully the excel spreadsheet which I will attach will clarify things.
Jeremy

Sign in to comment.

Accepted Answer

Roger Stafford
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.
  2 Comments
Jeremy
Jeremy on 7 Sep 2014
Hi Roger,
Thank you so much for your response. I will try your recommendation this evening when I return home from traveling. The screen shot I attached was just a small sample of the values that I wish to plot. Generally, based on the analysis I am performing, I will have a minimum of 150 data points and a maximum of 5000. If I wanted to use the mesh plot as you describe, how would I go about rearranging the data to interpolate/extrapolate them in such a way to make a mesh graph possible? Or if that is too complex to discuss here, can you provide me with some search terms I can use to do some research in Matlabs documentation.
If it helps, I will attach the full Excel file.
You have been very helpful. Thank you again.
Jeremy
Jeremy
Jeremy on 9 Sep 2014
Hi Roger,
I was able to plot the points as you explained above. However, the data would probably be easier to understand if it were in a mesh grid. I attempted to plot a mesh grid, but when I added the Z variable, it erred out saying that Z needed to be a matrix. What would I need to do to the data to make Z a matrix?
Thanks,
Jeremy

Sign in to comment.

More Answers (0)

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!