how to use quad ?

4 ビュー (過去 30 日間)
alaa akkoush
alaa akkoush 2018 年 1 月 7 日
コメント済み: Jan 2018 年 11 月 13 日
26219869_1573850829369116_6603952483732459120_n.jpg
I have to integrate the following function where alpha, w1, v1, k1 are discrete data (arrays of 194 elements each)... T is temperature, suchthat for every T I should have one G
function [G1] = try1(k1, alfa, w1, v1, T)
kb=1.38064852*10^(-23);
h=1.0545718*10^(-34);
c=h/(kb);
constant=(h^2)/((2*(2*pi)^3)*(kb));
q1 = csvread('q1.csv');
alfa= csvread('alfa.csv');
alldata = csvread('all.csv');
q1(end) = [];
w1 = alldata(:,1);
v1= alldata(:,7);
k1=q1*(pi/(5.431));
T=300:1:1000;
for i=1:length(T)
integrand = @(k1,alfa,v1,w1,T)(constant.*(1./T^2).*alfa.*w1.^2.*abs(v1).*exp(c*w1./T)./(exp(c*w1./T)-1).^2); G1=quad(@(k1)integrand(k1,alfa,v1,w1,T(i)),0,2.51365000000000);
end
end
  1 件のコメント
Jan
Jan 2018 年 11 月 13 日
Please do not delete questions, which got an answer already, because this is insulting for the persons, who spent their time for helping you.

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

回答 (1 件)

Star Strider
Star Strider 2018 年 1 月 7 日
We cannot run your code.
However, you appear to be integrating a function with 3 equal-sized vectors, ‘alfa’, ‘w1’, and ‘v1’, so the quadv (link) function appears to be most appropriate.
Note that if you have R2012a or later, the integral function with 'ArrayValued',true would be the best option.

カテゴリ

Help Center および File ExchangeParticle & Nuclear Physics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by