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

A Numerical solution in matlab

  1. Sep 26, 2016 #1
    Hi Guys,

    I'm trying to do a simple first-order, 1d (x-direction) simulation of mass transfer with the finite element toolbox in matlab for the following closed set of equations:




    (Please note: "X" is not to be confused with the lowercase spatial dimension "x")

    However, every time I cannot define the temperature (at least with exponential and erfc) without an error. Does anyone know if there is a proper syntax for this?

    I appreciate your help.
  2. jcsd
  3. Sep 26, 2016 #2


    Staff: Mentor

  4. Sep 26, 2016 #3
    This is the syntax I directly entered into the toolbox (I have also directly replaced "P" with the T-dependent expression). I also set x = X for the calculation. I am pretty sure one or two of my variables is not coded properly, particularly the temperature, T.

    X' = (K/TX_t)*((10^(A-(B/TX_t + C)))^2)/X_t

    TX_t = T0 + C*(t*exp(-X^2/t) + (X/2)*erfc(X/t))
  5. Sep 26, 2016 #4


    Staff: Mentor

    Okay, I'd start with building up the expression until it fails so then you have an even simpler failure to show us.

    Code (Matlab M):

    t=(1:0.1:11)           // create t array of (1,1.1,1.2,1.3 .... 10)
    x=(0:0.1:10)         // create X array of (0,0.1,0.2,0.3 ... 10)      same number of elements as t

    y = erfc(x./t)          // notice the use of ./ because here you want to do an element by element /
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted