0

I'm trying to solve this equation:

K=sqrt((R*T)/(4*pi*lambda))*integral from -inf to inf of exp(-((lambda+F*neta)/R*T-x)^2*R*T/4*lambda)/exp(x)+1 with regard to x

where, neta is an interval from 0 to 1 and the others symbols (R, T, F, lambda and pi) have constant values.

I tried to use these codes:

code 1

clear all;
close all;
clc;
F = 96485.34;
R = 8.3145;
T = 298.15;
lambda = 0.2;
neta=0:0.1:1;
pi=3.1415;
f=@(x) exp(-((lambda+F*neta)/R*T-x).^2*R*T/4*lambda)/(exp(x)+1);
Q=integral(f,-inf,inf);
k= sqrt((R*T)/(4*pi*lambda)).*Q

code 2

clear all;
close all;
clc;
F = 96485.34;
R = 8.3145;
T = 298.15;
lambda = 0.2;
neta=0:0.1:1;
pi=3.1415;
x= 0:100;
f(x)=exp(-((lambda+F*neta)/R*T-x).^2*R*T/4*lambda)/(exp(x)+1);
q=quadl('f', 0, 100);
k= sqrt((R*T)/(4*pi*lambda)).*q

but these codes return errors that I do not know to solve. Can someone help me, please?

thanks

  • Show us your code and what's going wrong! We can't solve it without knowing what your errors are. – Hugh Nolan Jul 17 '13 at 15:12
  • Hi Hugh Nolan,I started using the matlab short time ago. I tried different codes for this equation, but were frustated attempts ... I wish someone would help me writing it for me. :/ – Roberto Luz Jul 17 '13 at 17:44
  • First I tried to use this code: clear all; close all; clc; F = 96485.34; R = 8.3145; T = 298.15; lambda = 0.2; neta=2 pi=3.1415; f=@(x) exp(-((lambda+F*neta)/R*T-x).^2*R*T/4*lambda)/(exp(x)+1) Q=integral(f,-inf,inf) k= sqrt((R*T)/(4*pi*lambda)).*Q – Roberto Luz Jul 18 '13 at 13:15
  • After, I tried to use the "quadl" function: clear all; close all; clc; F = 96485.34; R = 8.3145; T = 298.15; lambda = 0.2; neta=2 pi=3.1415; x= 0:100 f(x)=exp(-((lambda+F*neta)/R*T-x).^2*R*T/4*lambda)/(exp(x)+1) q=quadl('f', 0, 100) k= sqrt((R*T)/(4*pi*lambda)).*q – Roberto Luz Jul 18 '13 at 13:29
  • In this case I was changing the intervals of x, because the program showed "Maximum variable size allowed by the program is exceeded" and because the authors who developed the equation said this integral function is finite only over a small range of x. – Roberto Luz Jul 18 '13 at 13:30
  • I still don't know what the problem is; does your code not work? How do you know if it does or not? Can you edit it into the main question with some formatting instead of having it in comments? – Hugh Nolan Jul 18 '13 at 13:37
  • I edited the main question – Roberto Luz Jul 19 '13 at 12:32
  • What are the errors that you are seeing? Could you post those as well? – Engineero Jul 19 '13 at 13:37

1 Answers1

0

The problem is with neta. If it is a scalar value then the code is fine. But how do you propose to integrate over the neta interval with respect to a different variable? What does that mean? I tried taking individual values for neta from 0 to 1 and calculating a Q value for each, but each Q returns 0.

Hugh Nolan
  • 2,508
  • 13
  • 15
  • The same happens to me when I use individual values ​​of neta, the result is zero. I want to get a value of k for each value of neta to be able to plot a graph k vs. neta. So I'm trying to solve numerically that integration. x is not known, the author just says that the integral function is finite only over a small range of x and converge by further decreasing the value of x. I'm trying to solve using different ranges of x. The other constants have their values pre-set, maybe I'm having trouble with the units of these constants. I'll check all the input values again. – Roberto Luz Jul 19 '13 at 14:16