someting wrong using interp2
Mostrar comentarios más antiguos
I would like to interpolate the values of an image I. The pixels of I have a specified position in point_seabed_e and point_seabed_n wich are not regularly spaced. I get: Error using griddedInterpolant Grid arrays must have NDGRID structure. How coul I fix it? Thanks
figure(20)
x=[-20:0.01:20];
y=[0:-0.05:-20];
[Xq,Yq] = meshgrid(x,y);
I=[SSS_ground_left SSS_ground_right];
Tq = interp2(point_seabed_e,point_seabed_n,I,Xq,Yq,'nearest');
surf(Xq,Yq,Tq)
view(2)
3 comentarios
KSSV
el 6 de Jul. de 2021
Can you tell us the dimensions of point_seabed_e,point_seabed_n,I ? I suspect the problem is in here.
Share your data.
Valeria Leto
el 6 de Jul. de 2021
Valeria Leto
el 6 de Jul. de 2021
Respuestas (1)
Image Analyst
el 6 de Jul. de 2021
2 votos
You can use scatteredInterpolant instead of griddedInterpolant. I'm attaching a demo.
5 comentarios
Valeria Leto
el 7 de Jul. de 2021
Image Analyst
el 8 de Jul. de 2021
So how did it work out? If it worked, please "Accept this answer".
Valeria Leto
el 8 de Jul. de 2021
Image Analyst
el 8 de Jul. de 2021
No. Sounds like it might need the Mapping Toolbox, which I don't have. Do you have that, and is it using that?
An image is an array in memory. It makes no difference where it came from - a PNG file on disk, or created by your program or whatever. Once it's in an array, all that is forgotten and all you need is the array.
Meshgrid can take floating point numbers - they don't have to be pixel coordinates.
Valeria Leto
el 8 de Jul. de 2021
Categorías
Más información sobre Interpolation en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!