Error using integral (line 85) A and B must be floating point scalars
Show older comments
Hello,
I have a function below. I have successfully integrated it when the value of d=0.5. However, I want to integrate it for d= 5*10^-6, d=5*10^-5..... . I don't want to change the data points manually and do the integration. I want to define d as a vector and save the final result of the integration as well. When I try to do so I got Matlab error of "Error using integral (line 85) A and B must be floating point scalars."

Any help is appreciated.
clear all clc format long
% definition of constants
% d= 5*10^-1;
d=linspace(5*10^-6,5*10^-3,100);
q=1.6*10^(-19);
k=1.38*10^(-23);
Lb= 44*10^-6;
phi=90*10^-3;
T=293;
f = @(x) (4*k*T/q)*( atanh(tanh(q*phi/(4*k*T))*exp(-x/Lb)) + atanh(tanh(q*phi/(4*k*T))*exp(-(2*d-x)/Lb)));
fun=@(x) 1./(cosh(q.*f(x)./(k*T)));
rho_ap= (2./d).*integral(fun,0,d./2);
Accepted Answer
More Answers (0)
Categories
Find more on Function Creation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!