matrix form numerical integration

2 ビュー (過去 30 日間)
john birt
john birt 2012 年 4 月 25 日
This code does not work
clear;
x = [1.0024 0.264 1.4334 1.46 0.0219 0.1;
1.0024 0.264 1.435 1.46 0.0220 0.1;
1.0024 0.264 1.4352 1.46 0.0221 0.1;
1.0024 0.264 1.4353 1.46 0.0222 0.1;
1.0024 0.264 1.4354 1.46 0.0222 0.1;
1.0024 0.264 1.4357 1.46 0.0223 0.1];
r = x(:,1); Y = x(:,2); q = x(:,3); K=x(:,4); L=x(:,5); c=x(:,6);
t = 0.1:0.1:0.6;
z = trapz(t,normcdf(((log(q./K)+t.*c.^2./2)./(c.*sqrt(t))),0,1));
If I just use one line of records, i.e
z = trapz(t,normcdf(((log(q(1)./K(1))+t.*c(1).^2./2)./(c(1).*sqrt(t))),0,1));
Then it works!!! What I dont understand is how to do this 'trapz' for each line of records in the vector 'x'.

採用された回答

Thomas
Thomas 2012 年 4 月 25 日
you are trying to perform trapezoidal numerical integration over a number of different values but the output z is not a vector.. MAybe you need something like this.. where you get a z for each line of input data..
clear;
x = [1.0024 0.264 1.4334 1.46 0.0219 0.1;
1.0024 0.264 1.435 1.46 0.0220 0.1;
1.0024 0.264 1.4352 1.46 0.0221 0.1;
1.0024 0.264 1.4353 1.46 0.0222 0.1;
1.0024 0.264 1.4354 1.46 0.0222 0.1;
1.0024 0.264 1.4357 1.46 0.0223 0.1];
r = x(:,1); Y = x(:,2); q = x(:,3); K=x(:,4); L=x(:,5); c=x(:,6);
t = 0.1:0.1:0.6;
for i=1:length(x)
z(i) = trapz(t,normcdf(((log(q(i)./K(i))+t.*c(i).^2./2)./(c(i).*sqrt(t))),0,1));
end
  1 件のコメント
john birt
john birt 2012 年 4 月 25 日
thank you.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by