Info

This question is closed. Reopen it to edit or answer.

hello)) I'm quite new in matlab and I try to solve integral which have variables from matrices.

1 view (last 30 days)
For example my integral looks like this
INTEGRAL(V.*(1-x./I).^(0.5), x, 0, I) So I have to take integral for x from 0 to I, where V and I are matrices with the size of NxM, BUT the most important I just have to take NxM integrals
INTEGRAL(V(i,j).*(1-x./I(i,j)).^(0.5), x, 0, I(i,j)) and in the end to get matrix NxM of integrals.
I tried
time2=@(Id, I, vp, a) (1./(vp.*(1-Id./I).^(a+1)).^(0.5));
time = zeros(size(vp));
for j=1:size1
for k=1:size2
time3=integral(@(Id)time2(Id, I(j,k), vp(j,k), a),0,I(j,k));
end
time(j,k)=time3;
end
but the message There may be a singularity, or the tolerances may be too tight for this problem. and my results unnormal
also I tried
time3 = arrayfun(@(I, vp) integral(@(Id)(1./(vp.*(1-Id./I).^(a+1)).^(0.5)),0,I), I, vp);
and I got my matrix but with non expected value and a message
Minimum step size reached near x = 0.293275. There may be a singularity, or the tolerances may be too tight for this problem.
  1 Comment
Marine
Marine on 27 Oct 2018
Edited: Marine on 27 Oct 2018
I've got it))
fun=@(Id, vp, I, a) 1./(vp.*(1-(Id./I).^(a+1)).^(0.5));
fun2 = @(I,vp)integral(@(Id)fun(Id, vp, I, a),0,I);
time3 =@(I,vp)arrayfun(fun2,I,vp);

Answers (0)

This question is closed.

Community Treasure Hunt

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

Start Hunting!