Decimal indexing for arrays in MATLAB
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Yuvarajendra Anjaneya Reddy
el 10 de En. de 2023
Comentada: Yuvarajendra Anjaneya Reddy
el 10 de En. de 2023
If I have a array of 11 elements, within the range 1 and 2, with a difference of 0.1, i.e, m = 1:0.1:2; to access the value of '1.4000' from the array 'm', the normal procedure is to write 'm(5)'. (index must be an integer)
Can I somehow index 'm(1.4)' and get the value 1.4000? (have a decimal value in the index)
3 comentarios
Bjorn Gustavsson
el 10 de En. de 2023
Sometimes I see 1-D interpolation that way - this require the array to have some simple interpretation of samples of a sufficiently smooth function that the samples in the array can be used to build useful estimates for your "fractional" indices. But indexing is to elements you have.
Yuvarajendra Anjaneya Reddy
el 10 de En. de 2023
Editada: Yuvarajendra Anjaneya Reddy
el 10 de En. de 2023
Respuesta aceptada
Bjorn Gustavsson
el 10 de En. de 2023
Have a look at the help and documentation for griddedInterpolant. That function might be what you're looking for. It creates a function that interpolates over a gridded data. For repeated calls this means that it has kept the structure for interpolation such that you won't redo all the set-up you'd do with repeated calls to interp2 again and again with repeated calls.
HTH
Más respuestas (0)
Ver también
Categorías
Más información sobre Resizing and Reshaping Matrices 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!