Files
3D_EDFM_SIM-X/core functions/preprocess/Ulit/dinterptable.m
T
2026-03-13 11:24:41 +08:00

14 lines
334 B
Matlab

function h = dinterptable(X, Y, u)
% n = length(X);
% DYDX = diff(Y) ./ diff(X);
% DYDX = DYDX([1, 1:end, end]);
% [~, b] = histc(u, [-inf;X;inf]);
% b = b - 1;
% b(b == 0) = 1;
% b(b == n) = n - 1;
% h = DYDX(b);
DYDX = diff(Y) ./ diff(X);
DYDX = DYDX([1, 1:end, end]);
[~, b] = histc(u, [-inf;X;inf]);
h = reshape(DYDX(b), [], 1);