How to interpolate a 3d surface with the different size of squares?
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a surface between a range -5 to 5 on both x and y axis. I would like to interpolate this surface with a new meshgrid data which has different size for each iteration. However, I cannot get the entire surface with interpolated new data. I only get the different size of squares. Is there a way to interpolate the original surface with different grid spacing ? Here is my code as well. Figure 1 is my original surface. and Figure 4 is interpolated surface which is missing the original surface itself. What I would like to have is Figure 4 in Figure 1.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/372581/image.jpeg)
L1 = 4;
L2 = 3;
L1 = L1;
[xP,yP] = meshgrid(n1:n2);
zP = real( L3*sqrt(1-((xP.^2)/ (L1^2)) - ((yP.^2)./ (L2^2))));
for i =1:length(CoordsX(:,1))
sqx=[min(CoordsX(i,:)), max(CoordsX(i,:))] ;
sqy=[min(CoordsY(i,:)), max(CoordsY(i,:))];
[x,y,z] =rotation(180-alpha,xP,yP,zP);
[Xq,Yq] = meshgrid(sqx,sqy);
Vq = interp2(xP,yP,z+z0_el,Xq,Yq,'cubic');
surf(Xq,Yq,Vq)
hold on
daspect([1 1 1])
end
댓글 수: 3
Asad (Mehrzad) Khoddam
2020년 10월 6일
The lower an upper limits of sqx and sqy are less than the original limits of xP and yP. So, you miss some data points.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!