Results 1 to 2 of 2

Math Help - matlab global variable

  1. #1
    Newbie
    Joined
    Apr 2010
    Posts
    23

    matlab global variable

    How can i define a global variable in matlab

    global a ;
    a = 56;

    i cannot use the value of a inside a function

    Please help me.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by AUCC View Post
    How can i define a global variable in matlab

    global a ;
    a = 56;

    i cannot use the value of a inside a function

    Please help me.
    At the console or in your script file initialise a

    Code:
    a=36;
    in the function have the line:

    Code:
    global a
    and the function will have access to a

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Matlab not returning variable as intended
    Posted in the Math Software Forum
    Replies: 7
    Last Post: April 18th 2010, 03:35 PM
  2. Replies: 1
    Last Post: February 15th 2010, 02:43 AM
  3. global max an global min
    Posted in the Calculus Forum
    Replies: 1
    Last Post: December 3rd 2008, 02:45 PM
  4. Help: Variable gain in Matlab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: September 11th 2008, 02:15 PM
  5. Global max/min.
    Posted in the Calculus Forum
    Replies: 5
    Last Post: March 28th 2008, 12:43 PM

Search Tags


/mathhelpforum @mathhelpforum