Azzera filtri
Azzera filtri

Conversion polar to Cartesian by interpolation

24 visualizzazioni (ultimi 30 giorni)
Paul
Paul il 2 Lug 2015
Modificato: Paul il 2 Lug 2015
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?

Risposte (1)

Steven Lord
Steven Lord il 2 Lug 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.

Categorie

Scopri di più su Interpolation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by