MATLAB (1st order differential equation)

Discussion in 'Homework Help' started by karas, Sep 13, 2018.

  1. karas

    Thread Starter Active Member

    Sep 8, 2011
    206
    0
    hi , i am trying to solve differential equation by matlab and i get these
    syms p(t) k p0 p15
    >> p = dsolve('Dp=k*p*exp(450/p)','p(0)=40,p(15)=95','t')
    Warning: Unable to find explicit solution.
    > In dsolve (line 201)

    and also i did this
    >> syms y(t) k
    ode = (diff(y,t) == k*y*exp(450/y));
    cond =[ y(0) == 40, y(15) == 95];
    ySol(t) = dsolve(ode,cond)
    Warning: Unable to find explicit solution.
    > In dsolve (line 201)

    my function is
    Dp=kp ln(450/p)
    p(0)=40 and p(15)=95 , k is constant
    can someone help please, i am new to MATLAB
     
    Last edited: Sep 13, 2018
  2. drc_567

    AAC Fanatic!

    Dec 29, 2008
    617
    89
  3. karas

    Thread Starter Active Member

    Sep 8, 2011
    206
    0
    Thanks for your help, i did follow the instruction and i still get this warning
    syms y(t) a
    eqn = diff(y,t) == a*y*exp(450/y);
    cond = [y(0)==40, y(15)==95];
    ySol(t) = dsolve(eqn,cond)
    Warning: Unable to find explicit solution.
    > In dsolve (line 201)
     
  4. karas

    Thread Starter Active Member

    Sep 8, 2011
    206
    0
    i have to use ode45 but the solution is not right , so what is wrong(i have 2 initial conditions and one constant k , did i write these initial condition and constant right in MATLAB?
    tspan = [0 300];
    y0 = 40;y15=95;
    [t,y] = ode45(@(t,y) 'k'*y*exp(450/y), tspan, y0,y15);
    plot(t,y,'-o')
     
  5. drc_567

    AAC Fanatic!

    Dec 29, 2008
    617
    89
    Please state the correct differential equation that you need to solve.
     
  6. karas

    Thread Starter Active Member

    Sep 8, 2011
    206
    0
    dy/dt=k*y*ln(450/y)
    y(0)=40 and y(15)=95 and k is constant
    Thanks
     
  7. drc_567

    AAC Fanatic!

    Dec 29, 2008
    617
    89
    One thing to test or try out ...
    If you are able to take the derivative of your first order original equation, that should yield a second order differential equation, which may be more acceptable to Matlab.
    If so far, you have all the syntax correct, then maybe that would be something to try.
     
Loading...