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 Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by