|
From: | Quentin Spencer |
Subject: | Re: Easy tutorial on how to make 3-dimensional graphics |
Date: | Thu, 12 Jan 2006 09:29:30 -0600 |
User-agent: | Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929) |
Tetsuji "Maverick" Rai wrote:
Thank you for your help... I'm a newbie on octave. Now I've begun writing a small function to make a 3-d plot, but I'm stuck at linspace(,,). Following function fails like octave:2> h100(1) error: linspace: npoints is 1, but x1 != x2 error: evaluating assignment expression near line 6, column 9 error: evaluating assignment expression near line 6, column 5 error: called from `h100' in file `/home/tetsuji/physics/hydrogen-atom/h100.m' - ----h100.m---- function h100(dn) a0 = 1; n = 1; x = z = linspace (-10, 10, dn); [xx, zz] = meshgrid (x,z); [theta,r] = cart2pol (zz,xx); r1 = 1 ./(n*a0); y = r1 .^1.5 * exp(-r1*r); y = y*y ./ pi; mesh(x,z,y); endfunction - ---------------
The last argument to the linspace function must be >1. Type help linspace to learn why.
Apparently x and z has a problem (I think I just borrowed this line from sombrero(n)). I must be doing something wrong, but don't know what's wrong.. Looking at sombrero(n), I see a single quote after linspace(-8,8,n) and a period before slash '/' or hat '^'..... What are they?? As for math, C++ is much easier to me... very unusual :(
In octave, a*b represents a matrix multiplication of matrices a and b (which requires that they have the correct dimensions). That is different than element-wise multiplication of a and b, so that is represented with the symbol ".*". Since the operators / and ^ also have special meanings for matrix operations, if you want to divide all of the elements in one vector or matrix by all of the elements in another of the same dimensions, you use "./"; the same is true for exponents and the ".^" operator. The single quote represents the transpose of a matrix.
In above function, x and z axes are on the horizontal plane, and y axis stands vertically. So are there any good online tutorial for octave (not document on www.octave.org)?
Maybe, but I don't know where. Maybe someone else can respond with suggestions.
-Quentin ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------
[Prev in Thread] | Current Thread | [Next in Thread] |