2015-10-02 2 views
0

J'ai écrit le code suivant dans scilab et je veux le tracer, mais l'intrigue ne ressemble pas à la 3D. Fondamentalement, le problème est des dimensions, x et y sont des matrices de 1 croix 5 et la fonction f est une matrice de 5 croix 5. J'ai essayé de faire des dimensions x et y 5 en utilisant meshgrid mais ensuite les fonctions ne peuvent pas me donner de résultat avec les valeurs modifiées de meshgrid (x, y). Le code entier est ici. Sera reconnaissant si quelqu'un m'aide.Dimensions isue en traceur 3D

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

Répondre

0

Votre problème est dû à la plage de f qui est très petite par rapport aux x et y.

Pour obtenir ce que vous attendez, vous pouvez procéder comme suit plot3d (x, y, f, flag = [2 4 4]); xtitle ("| Y31 (x, y) |"); ax = gca(); ax.cube_scaling = "on";

+0

Merci monsieur. c'est du travail –