Interpolation/Align two nonuniform grid in same time and space and convert it to a uniform Grid where both values are known at the same point.
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Nick Yin Larsen
el 2 de Mayo de 2016
Comentada: Nick Yin Larsen
el 6 de Mayo de 2016
Hello everyone,
I am not the professinal with Matlab and I have a problem to solve. I got a commercial program, which gives me the values of E-field and W/kg for a phantom.
When I export the values so I can use it in Matlab, the two coordinate systems doesn't fit to each other like one to one. I have made an illustration in 2D but it is a 3D problem tho.

It is two non-uniform grids, but it is in the same space
In my case I got two coordinate system, which you can see down below: The distance from each pixel/voxel, just like the E-field grid is between 1.9mm-0.9mm. I need to make the grid uniform and change the distance to 2mm for each pixel/voxel. And I have to know the E and Kg/W at the midpoint because I need them for further calculations. The E-field value is a complex number, which include real and imaginary numbers but we can forget about that for now.
So when I got my data, I got the x,y,z coordinates which are vectors and an E-value and a S-value, which fits with the coordinates as a n*m*l (matrix) since we need 3 positions to place the point.
if true
% code
load('E1.mat')
Ex=x_axis*1000; % 195x1
Ey=y_axis*1000; % 190x1
Ez=z_axis*1000; % 181x1
E %195x190x191
load('SAR1.mat')
KgWx=x_axis*1000; % 194x1
KgWy=y_axis*1000; % 189x1
KgWz=z_axis*1000; % 180x1
KgW %194x189x180
% Creating a mesh
[Exx, Eyy, Ezz] = meshgrid(Ey,Ex,Ez);
[KgWxx, KgWyy, KgWzz] = meshgrid(KgWy,KgWx,KgWz);
% Making a meshgrid with a spacing of 2 making more points
[Exx0, Eyy0, Ezz0] = meshgrid(min(Ex):2:max(Ex), min(Ey):2:max(Ey), min(Ez):2:max(Ez));
[KgWxx0, KgWyy0, KgWzz0] = meshgrid(min(KgWx):2:max(KgWx), min(KgWy):2:max(KgWy), min(KgWz):2:max(KgWz));
% As I said I also got my E-value and kgW-value corresponding to the x,y & z, so I though I could regard E & kgW as *v* for griddata(x,y,z, *v*,xq,yq,zq);
% The griddata function doesn't work somehow...
%vq = griddata(Exx,Eyy,Ezz,E,Exx0,Eyy0,Ezz0);
end
But I couldn't get further than that.... and I don't know to to combine the grids so they overlap each other.
It will be a great help if someone got an idea how to solve it, and thank you for your time! :)
0 comentarios
Respuesta aceptada
Matt J
el 2 de Mayo de 2016
Editada: Matt J
el 2 de Mayo de 2016
Since the original samples of both E and KgW are gridded, it sounds like you could just use do gridded interpolation twice. The only thing you need to do is specify different initial grid vectors {ne,me} for E and {nkgw,mgw} for KgW:
Fe=griddedInterpolant({ne,me},E)
Fkgw=griddedInterpolant({nkgw,mgw},KgW);
E_resamp=Fe({nCommon,mCommon},E);
KgW_resamp= Fkgw({nCommon,mCommon},E);
and a common set of grid vectors {nCommon,mCommon} for the target sampling.
7 comentarios
Matt J
el 5 de Mayo de 2016
Editada: Matt J
el 5 de Mayo de 2016
So right now it is interpolated but it is still non-uniform. So I can just make it uniform after this right?
Yes, but I wouldn't do it by interpolating twice. In other words, there is no need to first resample KgW onto a common grid with E and then resample again to make the grids uniform. That will compound interpolation/resampling error. Just resample each array separately onto the final uniform grid that you want, like I suggested in my original answer.
Más respuestas (0)
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!

