I keep getting the following error and I can't figure out why:
??? Error using ==> interp3 at 138 X, Y and Z must be matrices produced by MESHGRID. Use TriScatteredInterp instead of INTERP3 for scattered data.
Error in ==> contourslice at 124 vi = interp3(x, y, z, v, xi, yi, zi, method);
Error in ==> MagPlot at 21 contourslice(xg, yg, zg, maginterp,[],[],-0.4,20);
This is the associated script (x, y and z are vectors and mag is an array of several sets of data at x,y and z):
load('mag.mat'); coords=xlsread('NodeCoords.xls'); nodenum=coords(:,1); x=coords(:,2); z=coords(:,3); y=coords(:,4); clear coords
r=0:0.01:1; theta=0:pi/50:2*pi; zg=-0.45677:(-0.38877+0.45677)/9:-0.38877; [r,theta,zg]=meshgrid(r,theta,zg); xg=r.*cos(theta); yg=r.*sin(theta);
F=TriScatteredInterp(x,y,z,mag(:,1,700)); maginterp=F(xg,yg,zg); contourslice(xg, yg, zg, maginterp,[],[],-0.4,20);

1 commentaire

Sean de Wolski
Sean de Wolski le 13 Sep 2011
Good question (though you need to edit the code formatting)! +1 for being interesting.

Connectez-vous pour commenter.

 Réponse acceptée

Sean de Wolski
Sean de Wolski le 13 Sep 2011

0 votes

[r,theta,zg]=meshgrid(r,theta,zg);
xg=r.*cos(theta);
yg=r.*sin(theta);
When you multiply xg,yg by the sine and cosine of theta they lose their meshgrid-like properties (i.e. monotonicity) and their corresponding signs.
A good way to visualize this to look at the contour of the first slice of xg:
contour(xg(:,:,1))

Plus de réponses (0)

Catégories

En savoir plus sur Vector Fields dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by