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 件のコメント

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

サインインしてコメントする。

 採用された回答

Sean de Wolski
Sean de Wolski 2011 年 9 月 13 日

0 投票

[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))

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by