Results 1 to 5 of 5

Math Help - Graphing a 3D Plot in Matlab

  1. #1
    Junior Member
    Joined
    Jan 2009
    Posts
    27

    Graphing a 3D Plot in Matlab

    Here is the code I have so far:

    delete g286x08.txt; diary g286x08.txt
    clear; clc; close all; echo on
    % DMH
    % Gilat 286/08
    %
    P= 4*pi(.032/2*pi*8.31.*T)^(3/2).*v^2.*exp((-.032.*v^2)/(2*8.31.*T)) ;
    % R= 8.31
    % M= .032
    T=70:0.1:320 ;
    v= 0:0.1:1000 ;
    plot3(V,T,P)
    grid on
    %

    echo off; diary off

    where M is the molar mass of the gas in kg/mol, R=831 J/mol-K is the gas constant, T is the temperature in degrees K, and v is the molecules speed in m/s,

    Here is the question:
    Make a 3-D plot of P(v) as a function of v and T for V:[0,1000] (inclusive interval) and T:[70,320] in Kelvin for oxygen (molar mass .032 kg/mol)


    Thank you very much!
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Member
    Joined
    Mar 2007
    Posts
    206
    Awards
    1
    Try this:

    Code:
    n = 20;%resolution
    T=linspace(70,320,n) ;
    v= linspace(0,1000,n) ;
    [TT vv] = meshgrid(T,v);
    P = 4.*pi.*(.032./2.*pi.*8.31.*TT).^(3./2).*vv.^2.*exp((-.032.*vv.^2)./(2.*8.31.*TT));
    surf(TT,vv,P)
    xlabel T
    ylabel v
    zlabel P
    grid on
    Elbarto
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Jan 2009
    Posts
    27
    It just says 'undefined variable T' and then says there is an error in P=....
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Member
    Joined
    Mar 2007
    Posts
    206
    Awards
    1
    T is defined on the second line so I don't know why u would be getting that message. Did u past all code inside a single mfile and run
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Junior Member
    Joined
    Jan 2009
    Posts
    27
    Yeah sorry dude, was trying not to copy and paste it, just so I could understand how you did it. But I rearranged it and got it to work, so thanks a lot dude. i appreciate it!
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. 3D plot of z = (Matlab)
    Posted in the Math Software Forum
    Replies: 4
    Last Post: July 14th 2011, 09:22 PM
  2. loglog plot in MATLAB
    Posted in the Math Software Forum
    Replies: 2
    Last Post: March 31st 2011, 08:43 PM
  3. Kac Formula plot with MatLab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: March 14th 2010, 08:33 AM
  4. matlab 3D-4D graphic plot
    Posted in the Math Software Forum
    Replies: 6
    Last Post: October 25th 2008, 03:53 AM
  5. MatLab Plot
    Posted in the Math Software Forum
    Replies: 1
    Last Post: August 2nd 2008, 11:59 AM

Search Tags


/mathhelpforum @mathhelpforum