Tuesday 15 April 2014

numerical methods - Integrate function of two variables with respect to only one variable in matlab -



numerical methods - Integrate function of two variables with respect to only one variable in matlab -

i want integrate 1d function using quadgk different value of parameter contained within integrand. there easy way this? below illustrates problem:

function [out] = integrand(x,t) #calculations end t = linspace(0,1,10); q = quadgk(@integrand,0,inf, opt_param = t); #apply quadgk on integrand each value in t plot(t, q) # q function of t

can for loop?

function [out] = integrand(x,t) %calculations end t = linspace(0,1,10); q = zeros(size(t)); % pre-allocate q k=1:length(t) q(k) = quadgk(@(x)integrand(x,t(k)),0,inf); %apply quadgk on integrand each value in t end plot(t, q) % q function of t

more details on parameterising functions @ http://www.mathworks.co.uk/help/matlab/math/parameterizing-functions.html.

matlab numerical-methods

No comments:

Post a Comment