# How can this probability function be entered?

1 visualizzazione (ultimi 30 giorni)
Matthew Nanos il 8 Mar 2015
Commentato: Star Strider il 9 Mar 2015
I'm very new to matlab. I want to take this equation and use matlab to graph it:
I used this code
The variable P is created but it has a value for the first element, then all zeros.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Star Strider il 8 Mar 2015
You have to vectorise your assignment for ‘P’:
k = 1.3806488E-23;
e = 6.0217657E-19;
z = 2;
Vh = 1E-3;
T1 = 25+273.15;
T2 = 37+273.15;
V = linspace(-0.1, 0.09);
VV = V-Vh;
P = 1./(1+exp(-z*e*(VV/(k*T1))));
figure(1)
plot(V, P)
grid
##### 2 CommentiMostra NessunoNascondi Nessuno
Matthew Nanos il 9 Mar 2015
Thank you
Star Strider il 9 Mar 2015
My pleasure!

Accedi per commentare.

### Più risposte (1)

Greig il 8 Mar 2015
Change P to
P = (1./(1+exp(-z*e*(VV/(k*T1)))));
Since the (1+exp(..)) is a vector you have to use array division (./)
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by