numerical integration

2 次查看(过去 30 天)
john birt
john birt 2012-4-25
I have code
c=0.2; t = 0.00001:0.0001:20; trapz(t,normcdf(((log(q(1)/K(1))+t*c^2/2)/(c*sqrt(t))),0,1)*stblpdf(t,0.5,1,12,0,'quick'));
but then I want to use vectors for 'q' and 'K' so I coded
c=0.2; t = 0.00001:0.0001:20; z = trapz(t,normcdf(((log(q./K)+t.*c.^2/2)./(c.*sqrt(t))),0,1).*stblpdf(t,0.5,1,12,0,'quick'));
but get the error
??? Error using ==> plus
Matrix dimensions must agree.
how can this be done?

采纳的回答

Walter Roberson
Walter Roberson 2012-4-25
You would get that error if the length of q is not the same as the length of t. Are you attempting to calculate for each pair q(J), t(K) ? If you are then see bsxfun() or ndgrid()

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by