Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB, 3D plotting

Tags:
  1. Jan 21, 2014 #1
    Hi Friends,
    The code below is for 2D ploting in Matlab, I want to change it in 3D, please if any one know how to do this.let me know
    thanks in advance


    figure(1);
    popcosts=[pop.Cost];
    repcosts=[rep.Cost];
    plot(popcosts(1,:),popcosts(2,:),'b.');
    hold on;
    plot(repcosts(1,:),repcosts(2,:),'r*');
    hold off;
    legend('Normal Particles','Repository Particles');
    xlabel('f_1');
    ylabel('f_2');
     
    Last edited by a moderator: Jan 21, 2014
  2. jcsd
  3. Jan 21, 2014 #2

    kreil

    User Avatar
    Gold Member

    What is your z variable? You need a third variable of values to plot in 3D.

    For example,

    surf(popcosts(1,:),popcosts(2,:),popcosts(3,:))

    You could also use surfc, contour, plot3, and countless other functions for 3D plotting. Answer the below questions, and then click the following link:

    http://www.mathworks.com/help/matlab/2-and-3d-plots.html

    1. What kind of plot do you want?
    2. What are your 3 variables?
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: MATLAB, 3D plotting
  1. 3D Matlab plot (Replies: 4)

  2. Matlab 3D Scatter Plot (Replies: 4)

  3. 3D plot using Matlab (Replies: 1)

Loading...