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

MATLAB simple code

  1. Feb 21, 2010 #1
    Hi Guys,

    I am trying to plot a simple Maxwell-Boltzmann Equation curve that shows me the probability of opening an ion gated channel. The issue I am having is the output shows me just a linear horizontal line that is around 0.5 probability which makes no sense given my inputs.

    Please take a look at my code below and help me if possible:

    >> q = 1.6*10^(-19);
    >> V = -100:1:40;
    >> k = 8.617*10^(-5);
    >> P = 1./(1+ exp(-z*q*((V+15)./(k*293.15))));
    >> plot(V,P);

    Basically I am plotting voltage ranges on the effect of probability that the ion gated channel for a membrane is open. It is a divalence, with room temp, and Voltage at 0.5 probability is -15mV.
     
  2. jcsd
  3. Feb 21, 2010 #2

    Mark44

    Staff: Mentor

    What's the value of z? I'm guessing that you haven't initialized it, so you're getting P = 1/(1 + 1) = 0.5.

    By not initializing z, the value of your exponential expression is just 1.
     
  4. Feb 21, 2010 #3
    sorry about that z was intialized to 2, i still get an almost straight line instead of a parabolic distribution that should be evident
     
  5. Feb 21, 2010 #4

    Mark44

    Staff: Mentor

    Is P defined as an array? Is there some sort of do loop that calculates values for P? It would probably be helpful if you provided your complete code.
     
  6. Feb 22, 2010 #5
    If z wasn't initialized, there would be an error. It wouldn't be treated as 0. Also, the code as shown is complete and will run as is, provided z set equal to 2.

    The reason you are getting a constant 0.5 is simply because the exponential is evaluating to 1 given your numbers. (V+15)/ (kB T) is ranging from about -3000 to 2000, while you are multiplying it by q = 1.6 x 10^-19. That gives you something on the order of 10^-16, the exponential of which is 1 for all intents and purposes.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: MATLAB simple code
  1. Matlab codes (Replies: 2)

  2. Matlab code (Replies: 0)

  3. Error code in Matlab (Replies: 3)

Loading...