Simultaneously interpolating over multiple rows of a matrix.
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Brandon
el 7 de Abr. de 2021
Comentada: Brandon
el 7 de Abr. de 2021
I have a matrix ("mat") of size N*M where each row is defined over a grid ("grid"), and I would like to obtain interpolated values ("vals") over a subset of rows of length K ("ind1") over a query vector ("qvec"). This is part of a larger iterative routine, where the size and elements of ind1 and the elements of mat and qvec change each iteration. I'm currently using a for-loop over the subset of rows, interpolating one at time. Here is a simplified example:
K = length(ind1);
vals_temp = zeros(N,1);
for ii = 1:K
ind2 = ind1(ii);
vals_temp(ind2,1) = interp1(grid,mat(ind2,:),qvec(ind2));
end
vals = vals_temp(vals_temp>0);
I would like to be able to do this without a loop because this is very time consuming. I’m thinking that I can use interpn over the entire subset ind1, but I’m having trouble figuring out how to make the inputs conformable. Any help would be appreciated.
0 comentarios
Respuesta aceptada
Más respuestas (1)
Ver también
Categorías
Más información sobre Interpolation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!