Integration of a piecewise function

xavier roguiez xr at geo.hmg.inpg.fr
Sat Oct 16 14:43:37 CEST 2010


Hello,

I've got the following problem, i need to perform successively two
integrations along the x axis of a beam.
It's consumming large time and memory. And the calculation doesn't
converge at the end...

I've tried to cut my problem in two parts. I've performed (quite
rapidely) the first integration and store the result in a vector Vnum.

And i've (naively) try to build a function which is giving the value of
V at the x position (in order to avoid the last integration).

function [V]=TranchantNum(u,x,Vnum)
for i=1:size(x,1),
   if (u<=x(i)) then
     V=Vnum(i);
     break,
   end
 end
endfunction

where Vnum is the result of the last integration, x is a vector which
contains the position (0:0.1:50)', and u is the position along the x
axis where I need the information.

Then
x1=x
for i=1:size(x,1),
  M(i)=integrate('TranchantNum(x,x1,Vnum)','x',0,x(i))
end
The loop is ok for first value, because Vnum is quite continuous, but
for further values, discontinuities appears in Vnum.

And I've got the following messages :
-->integrate('TranchantNum(x,x1,Vnum)','x',0,15)
 !--error 24
Problème de convergence ...

at line      70 of function integrate called by :
integrate('TranchantNum(x,x1,Vnum)','x',0,15)

Does anybody has an idea to solve or reformulate my problem ?

Thanks in advance for any information
xavier

PS : I join the data of x and Vnum, in order to test my code, i'm
executing the following code
temp=read('donnees.txt',548,2);
x=temp(:,1);
Vnum=temp(:,2);

PS : i've tried another formulation of TranchantNum
function [y]=TranchantNum2(u,x,Vnum)
  pas=0.1
 y=sum(bool2s((x>=u-pas/2)&(x<=u+pas/2)).*Vnum)
endfunction
which is more compact, but the result is the same.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: donnees.txt
URL: <https://lists.scilab.org/pipermail/users/attachments/20101016/58c4f148/attachment.txt>


More information about the users mailing list