Rotating values within a meshgrid

조회 수: 11 (최근 30일)
Christina Boyce
Christina Boyce 2019년 10월 2일
답변: darova 2019년 10월 2일
I have X,Y,Z values from a bathymetry survey. I am able to create a meshgrid and grid the data just fine. The issue that I am experiencing is that since my survey area is not perfectly square (it is more of a diagonal rectangle, see below), there are an etreme amount of NaNs within my meshgrid. I have tried changing the NaNs to a number (like 0), as well as interpolating in the griddata function, but this is misrepresenting what is in my data. Ultimatly, I am trying to preform a SVD for the matrix, but I cannot have NaNs to run this function. The simplest solution I can think of is to 'rotate' the data within my meshgrid. Can anyone give advice?
Thank you,
survey area.PNG
meshgrid.PNG
Thank you,
Christina

채택된 답변

darova
darova 2019년 10월 2일
So maybe rotate your data and apply griddata() again
a = 45;
R = [cosd(a) sind(a); -sind(a) cosd(a)];
V = R*[x(:) y(:)]';
xnew = V(1,:);
ynew = V(2,:);
rangex = linspace(min(xnew),max(xnew),30);
rangey = linspace(min(ynew),max(ynew),30);
[X1,Y1] = meshgrid(rangex,rangey);
Z1 = griddata(xnew,ynew,z,X1,Y1);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by