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

Matlab: what is the right 3D plotting function for my code?

  1. Apr 22, 2013 #1
    Hi all, I have a simple question about 3D plotting.

    Consider this simple loop, which provides y and O for any x. and I am able to plot y vs O for given x.

    for Omega=0:.01:5

    y(i)=(x*Omega^2);

    O(i)=Omega;

    i=i+1;

    end

    now consider I want to change the value of x, for x=0:.1:3 and plot the group of y's and O's in one plot.(y~O~x) which one of the 3D plot functions are right for this purpose and what will be the code?

    I would appreciate you time and help,

    Romik
     
  2. jcsd
  3. Apr 24, 2013 #2

    jhae2.718

    User Avatar
    Gold Member

    You'll probably want to use meshgrid and surf. Something like:
    Code (Text):

    x = [color=#008000]linspace[/color](0, 3, 100);
    omega = [color=#008000]linspace[/color](0, 5, 100);
    [X Omega] = [color=#008000]meshgrid[/color](x, omega);
    Y = X [color=#666666].*[/color] Omega [color=#666666].^[/color]2;
    surf(X, Y, Omega); [color=#408080][i]% Or whatever order you want to plot...[/i][/color]
     
     
    Last edited: Apr 24, 2013
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Matlab: what is the right 3D plotting function for my code?
  1. Matlab 3D Scatter Plot (Replies: 4)

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

  3. MATLAB, 3D plotting (Replies: 1)

Loading...