MATLAB: How to solve integral of vector How do I use the integral function on a vector? I tried this: fun=@(s)expm(Ae*s)*h q=@(t)integral(fun,0,t) Ae is a matrix and h is a vector. Best Answer You have to specify ‘'ArrayValued',true’ in the integral call. To integrate over a vector ‘t’, use the arrayfun function:Ae = randi(9,3); % Create ‘Ae’h = randi(9,3,1); % Create ‘h’fun=@(s)expm(Ae.*s)*h;q=@(t)integral(fun,0,t, 'ArrayValued',true) % Specify 'ArrayValued',trueQ1 = arrayfun(q, (0:5), 'UniformOutput',false); % Integrate Over Vector ‘t’ Related SolutionsMATLAB: Integral3 I use integrl3 to calculate a simple 4th integral but… integral(@(w) integral3(@(x,y,z) fun(x,y,z,w),-1,1,-1,1,-1,1),-1,1,'ArrayValued',true) MATLAB: Why i get this error when using integral The solution is given in the error message:an = (2/T) * integral(@(t) exp((10 - t) / 2).*cos(2*pi*f0*n*t), 0, T, 'ArrayValued',true);By the way: You don't need to specify the t-vector ; "integral" will use ist own spatial gridding.Best wishesTorsten. Related QuestionAnonymous function representation using integralIntegrating a constant in MATLABError while executing integral function
Best Answer