필터 지우기
필터 지우기

Conversion polar to Cartesian by interpolation

조회 수: 7 (최근 30일)
Paul
Paul 2015년 7월 2일
편집: Paul 2015년 7월 2일
Hi every one
I have a strange error in my code
I have convert the data from Cartesian to the polar as bellow:
Error using interp2>makegriddedinterp (line 237)
Input grid is not a valid MESHGRID.
Error in interp2 (line 136)
F = makegriddedinterp(X, Y, V, method,extrap);
can any body solve this problem?
  댓글 수: 1
Thorsten
Thorsten 2015년 7월 2일
After you define u, what are you trying to achieve?

댓글을 달려면 로그인하십시오.

답변 (1개)

Steven Lord
Steven Lord 2015년 7월 2일
INTERP2 requires gridded data. The X and Y coordinate data you converted from polar is not gridded.
theta = (0:1/4:2)*pi;
rad = 0:5;
[T, R] = meshgrid(theta, rad);
[X, Y] = pol2cart(T, R);
Z = X.^2+Y.^2;
plot3(X, Y, Z, 'ko');
You may want to rotate that data to convince yourself that it's a bowl shape. To obtain the values of other points on the bowl, you will need to interpolate this using a tool that can interpolate scattered data:
[x2, y2] = meshgrid(-3:0.25:3);
S = scatteredInterpolant(X(:), Y(:), Z(:));
z2 = S(x2, y2);
hold on
plot3(x2, y2, z2, 'r+');
You should now see a "mesh" of + signs, like a piece of paper towel resting on the inner surface of the bowl.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by