Hi, I am trying to convert the following equation to matlab code. I have a bunch of defined constants above this code but I am trying to figure out if my formatting is correct since I keep getting the wrong answer. I need to multiply the two functions and they are dependant on the variable E, everything else is a constant. Thanks!Capture.PNG
Capture2.PNG

4 件のコメント

David Hill
David Hill 2019 年 9 月 27 日
Is E a row vector and all others are scalar?
Christos Papedo
Christos Papedo 2019 年 9 月 27 日
編集済み: Christos Papedo 2019 年 9 月 27 日
Yes exactly. Here are my variable definitions. My N matrix should be in the order of 10^21 but I am getting 10^-12
clear, clc;
m = 9.11*10^(-31);
h = (6.63/(2*pi))*10^(-34)*(6.242*10^18); % corrected to change J to eV
q = 1.6*10^(-19);
k = 1.38*10^(-23)*(6.242*10^18); % corrected to change J to eV
T = 300;
Ef = 0; %Assuming fermi level is at 0
Ec = Ef + .55;
E = Ec:.001:Ec +.3;
g = (1/(2*(pi^2)*(h^3)))*((2*m)^(3/2))*(sqrt(E-Ec));
f = 1./(1+exp((E-Ef)./(k*T)));
N = g.*f;
Jon
Jon 2019 年 9 月 27 日
編集済み: Jon 2019 年 9 月 27 日
For the future, it is good to use the insert code button on the Answers toolbar to insert code rather than using a screen shot. Then people can easily copy and paste from there to try your code without having to retype it.
madhan ravi
madhan ravi 2019 年 9 月 27 日
Always post the code, don’t let others type the same code.

サインインしてコメントする。

 採用された回答

Jon
Jon 2019 年 9 月 27 日
編集済み: Jon 2019 年 9 月 27 日

0 投票

% note .* to get element by element multiplication
% ./ for element by element division
g = 1.0/(2*pi^2*h^3)*(2*m)^(3/2)*sqrt(E-Ec)
f = 1.0 ./(1+exp((E-Ef)/(k*T)))
N = g.*f
Sorry I didn't notice you already had some code for N = g.*f at the bottom of your original post, I just saw the typeset equations. Maybe this is equivalent what you already have. If so I guess there is a problem in your definition of the constants. In any case you have some unecessary parenthesis and also the ./ in your first equation is not needed when the denominator is a scalar.
You also have some apparently unecessary parentheses in your definition of the constants. This is a good reference on Matlab's precedence rules https://www.mathworks.com/help/matlab/matlab_prog/operator-precedence.html

1 件のコメント

Christos Papedo
Christos Papedo 2019 年 9 月 27 日
Thank you very much.

サインインしてコメントする。

その他の回答 (1 件)

SUFIZATUL AIN MAMAT
SUFIZATUL AIN MAMAT 2022 年 4 月 26 日

0 投票

f\left(x\right)=-3x^3+5x^2+14x-16

カテゴリ

ヘルプ センター および File ExchangeFunctions についてさらに検索

製品

リリース

R2019b

タグ

質問済み:

2019 年 9 月 27 日

回答済み:

2022 年 4 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by