3D绘图中的尺寸问题

时间:2015-10-02 15:05:00

标签: scilab

我在scilab中编写了以下代码,并想绘制它,但情节看起来不像3D。基本上问题是尺寸,x和y是1交叉5矩阵,函数f是5交叉5矩阵。我试图通过使用meshgrid来制作x和y 5维,但是函数不能给我带有meshgrid(x,y)的修改值的结果。整个代码就在这里。

clear; clc;
//Defining the range of Cartesian coordinates (x,y,z)
x = linspace(1,30,5);
y = linspace(0,30,5);
z = linspace(0,30,5);
//------------------------------------------------------------------------------
//This funciton transform Cartesian to Spherical coordinates
function [r, theta, phi]=cart2sph(x, y, z)  
  r = sqrt(x^2+y^2+z^2);
  theta = atan(y./x) 
  phi = acos(z./sqrt(x^2+y^2+z^2))'
endfunction
//------------------------------------------------------------------------------
//To get the spherical coordinates from Cartesian uing the above funciton
[r, theta, phi]=cart2sph(x, y, z)  
//------------------------------------------------------------------------------
//Defining spherical hormonic as a funciton of shperical coordinates here.
function [y]=Y(l, m, theta, phi)  
  if m >= 0 then
     y = (-1)^m/(sqrt(2*%pi))*exp(%i*m*phi)*legendre(l, m, cos(theta), "norm")
  else
     y = 1/(sqrt(2*%pi))*exp(%i*m*phi)*legendre(l, -m, cos(theta), "norm")
  end      
endfunction
l = 1; m = -1;
f = Y(l,m,theta,phi); 
//I got the funciton value in spherical coordinates and 
//that spherical coordinates are funciton of Cartesian coordinates. 
//So basically funciton Y is a funciton of Cartesian coordinates (x,y,z). 
//Next to plot funciton Y against (x,y)
//------------------------------------------------------------------------------
clf(); 
plot3d(x,y,f,flag=[2 4 4]); xtitle("|Y31(x,y)|");

1 个答案:

答案 0 :(得分:0)

你的问题是由于f的范围与x和y相比非常小。

为了获得您的期望,您可以按照以下步骤进行操作     plot3d(x,y,f,flag = [2 4 4]); xtitle(" | Y31(X,Y)|&#34);     AX = GCA();     ax.cube_scaling ="上&#34 ;;