3D绘图中的尺寸问题

问题描述 投票:0回答:1

我在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)|");
scilab
1个回答
0
投票

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

为了得到你所期望的,你可以按照plot3d(x,y,f,flag = [2 4 4])进行操作; xtitle( “| Y31(X,Y)|”); AX = GCA(); ax.cube_scaling = “上”;

© www.soinside.com 2019 - 2024. All rights reserved.