2015-10-02 39 views
0

我在scilab中編寫了下面的代碼,並且想要繪製它,但情節看起來不像3D。基本上問題是尺寸,x和y是1個交叉5矩陣,函數f是5個交叉矩陣。我試圖通過使用meshgrid來製作x和y 5維,但是這些函數無法給我帶來修改後的meshgrid(x,y)值。整個代碼在這裏。感謝有人幫助我。三維繪圖中的尺寸isue

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)|"); 

回答

0

你的問題是由於f的範圍,這是非常小的x和y的比較。爲了得到你期望的結果,你可以按照如下步驟進行: plot3d(x,y,f,flag = [2 4 4]); xtitle( 「| Y31(X,Y)|」); ax = gca(); ax.cube_scaling =「on」;

+0

謝謝先生。是工作 –