I am facing a problem in numerical integration which has a function of form f(x)=exp(-E/T) where first it has to be integrated over T which has bounds T0 and T1 assuming 'E' as variable.Later on it has to be integrated again over 'E' with E0 & E1.
2 views (last 30 days)
Show older comments
VENKATA PARAKASH PONUGOTI
on 28 Jun 2015
Answered: Walter Roberson
on 28 Jun 2015
The exact equation is of the form

i have tried with "quad" function
f =@(T,E) exp(-E/T);
%--------------bounds-----------------%
T0 =300;
T1 =1400;
E0 =40;
E1 =50;
%------------------------------------%
e = 40:0.1:50;
E = e';
[m,n] = size(E);
sz =size(E);
z = zeros(sz);
for k = 1:numel(m)
g= @(T)f(T,E(m));
z(m) =quad(g,T0,T1);
end
and with function written in the form as
g = @(c) (integral(@(x) (exp(-c/x)),T0,T1));
so that it returns a value for every g(E),but both the codes are giving the same error as "Error using / Matrix dimensions must agree"
Would you please recommend a way to solve this problem and successfully integrate the function numerically.
0 Comments
Accepted Answer
Walter Roberson
on 28 Jun 2015
g = @(c) (integral(@(x) (exp(-c./x)),T0,T1));
Remember that integral will pass a vector of values in, and that the "/" operator is for matrix division not for element-by-element division.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!