Converting equation to matlab

7 vues (au cours des 30 derniers jours)
Christos Papedo
Christos Papedo le 27 Sep 2019
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 commentaires
Jon
Jon le 27 Sep 2019
Modifié(e) : Jon le 27 Sep 2019
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 le 27 Sep 2019
Always post the code, don’t let others type the same code.

Connectez-vous pour commenter.

Réponse acceptée

Jon
Jon le 27 Sep 2019
Modifié(e) : Jon le 27 Sep 2019
% 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 commentaire
Christos Papedo
Christos Papedo le 27 Sep 2019
Thank you very much.

Connectez-vous pour commenter.

Plus de réponses (1)

SUFIZATUL AIN MAMAT
SUFIZATUL AIN MAMAT le 26 Avr 2022
f\left(x\right)=-3x^3+5x^2+14x-16

Tags

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by