# MATLAB simple code

1. Feb 21, 2010

### foobag

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. Feb 21, 2010

### 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.

3. Feb 21, 2010

### foobag

sorry about that z was intialized to 2, i still get an almost straight line instead of a parabolic distribution that should be evident

4. Feb 21, 2010

### 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.

5. Feb 22, 2010

### matonski

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.