Hello Stephane,
thank you for overloading dsearch, indeed it performs what I want.
I also tested the interpolation approach, adapted from your previous post, which performs well :
function yp= interp0(x,y,xp)
//Stephane Mottelet décembre 2023 - 0-D interpolation, piecewise constant function definition - https://scilab.discourse.group/t/0-d-interpolation-piecewise-constant-function-definition/308
// i = floor(interp1(x,1:length(x),xp,"linear","edgevalue"))
i = floor(linear_interpn(xp,x,1:length(x),"C0")) //a priori plus rapide qu'interp1
yp = y(i)
endfunction
//------------------------------------------------------------------------------
function ip= interp0dtm(dtm,dtmp)
//trouver les index des intervalles bornes dtm ([..[) contenant dtmp
dtn= dtm.date+dtm.time/3600/24
dtnp= dtmp.date+dtmp.time/3600/24
ip= interp0(dtn,1:length(dtn),dtnp)
endfunction
//-----------------------------------------------------------------------------
Thanks,
David