Results 1 to 2 of 2

Math Help - What is wrong with my matlab function?

  1. #1
    Junior Member
    Joined
    Jul 2009
    Posts
    67

    What is wrong with my matlab function?

    I have been trying to figure this out for a couple of hours now. Help please.

    Okay here is the mfile I'm using. Titled f

    function zi = f(x, y)
    q = .6; %transmisiivity of solar glazing
    s = 1; %absorptivity of adobe walls
    c = 0; %thermal capacitance of the maternity house
    d = 4.55; %area of solar collector (m^2)
    r = 198.63; %1/Rt
    e = 5; %ambient temp.
    zi =(((q.*s.*c.*d)-((y-e)/r))./c);


    Then we typed into the command window the following string:

    >> a = 0;
    >> b = 86400;
    >> y0 = 20;
    >> [x,y]=ode45('f',[a,b],y0)


    The values resulted in

    x = 0.000000000
    0.000000000000

    etc

    y = NaN
    NaN
    NaN
    etc.

    These values are obviously wrong, help please!
    Last edited by mr fantastic; October 25th 2010 at 11:07 PM. Reason: Title.
    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 radioheadfan View Post
    I have been trying to figure this out for a couple of hours now. Help please.

    Okay here is the mfile I'm using. Titled f

    function zi = f(x, y)
    q = .6; %transmisiivity of solar glazing
    s = 1; %absorptivity of adobe walls
    c = 0; %thermal capacitance of the maternity house
    d = 4.55; %area of solar collector (m^2)
    r = 198.63; %1/Rt
    e = 5; %ambient temp.
    zi =(((q.*s.*c.*d)-((y-e)/r))./c);


    Then we typed into the command window the following string:

    >> a = 0;
    >> b = 86400;
    >> y0 = 20;
    >> [x,y]=ode45('f',[a,b],y0)


    The values resulted in

    x = 0.000000000
    0.000000000000

    etc

    y = NaN
    NaN
    NaN
    etc.

    These values are obviously wrong, help please!
    You are dividing by c which is set to zero.

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 1
    Last Post: February 9th 2010, 04:29 AM
  2. Replies: 4
    Last Post: January 28th 2010, 10:32 PM
  3. Replies: 3
    Last Post: July 29th 2009, 02:45 AM
  4. wrong code at matlab - meshgrid and 3d plot
    Posted in the Math Software Forum
    Replies: 2
    Last Post: June 30th 2009, 01:17 AM
  5. Matlab - memmapfile Memory Usage, what's wrong?
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 19th 2009, 04:29 AM

Search Tags


/mathhelpforum @mathhelpforum