Plot Maxwell-Boltzmann Equation w/ MATLAB Code

  • Context: MATLAB 
  • Thread starter Thread starter foobag
  • Start date Start date
  • Tags Tags
    Code Matlab
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
4 replies · 7K views
foobag
Messages
75
Reaction score
0
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.
 
Physics news on Phys.org
foobag said:
>> P = 1./(1+ exp(-z*q*((V+15)./(k*293.15))));
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.
 
sorry about that z was intialized to 2, i still get an almost straight line instead of a parabolic distribution that should be evident
 
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.
 
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.