Conversion polar to Cartesian by interpolation
24 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Antworten (1)
Steven Lord
am 2 Jul. 2015
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.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!