Plot Maxwell-Boltzmann Equation w/ MATLAB Code

  • Context: MATLAB 
  • Thread starter Thread starter foobag
  • Start date Start date
  • Tags Tags
    Code Matlab
Click For Summary

Discussion Overview

The discussion revolves around plotting the Maxwell-Boltzmann Equation using MATLAB code to analyze the probability of opening an ion gated channel. Participants are addressing issues related to the output of the code, which is not producing the expected parabolic distribution.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Homework-related

Main Points Raised

  • One participant reports that the output is a linear horizontal line around 0.5 probability, which seems incorrect given the inputs.
  • Another participant questions the initialization of the variable z, suggesting that if it is not set, the output would default to 0.5.
  • A participant clarifies that z was initialized to 2, yet the output remains a straight line instead of the expected distribution.
  • There is a suggestion to check if P is defined as an array and whether a loop is needed to calculate values for P.
  • Another participant asserts that if z were uninitialized, it would cause an error, and explains that the output is constant due to the exponential term evaluating to 1 based on the provided values.
  • It is noted that the range of (V+15)/(k*293.15) results in a very small number when multiplied by q, leading to an exponential value that approximates 1.

Areas of Agreement / Disagreement

Participants express differing views on the cause of the constant output, with some attributing it to the initialization of variables and others pointing to the mathematical evaluation of the exponential function. The discussion remains unresolved regarding the exact reason for the output issue.

Contextual Notes

There are potential limitations in the code related to variable initialization and the mathematical behavior of the exponential function, which may not be fully explored in the discussion.

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.
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
Replies
3
Views
2K
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 2 ·
Replies
2
Views
3K