[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

function file question and plot using polar coordinates

From: Tetsuji \"Maverick\" Rai
Subject: function file question and plot using polar coordinates
Date: Thu, 12 Jan 2006 03:30:14 +0900
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a1) Gecko/20060101 SeaMonkey/1.5a

Hash: SHA1

Two newbie questions in one email :)  Because the online document (and
written document) doesn't help me in this part....

#1. I am trying to write a function file, but octave complains loading
the function file; e.g. I made a file of sombrero2(n) like (just copied
"type sombrero")
- ----------sombrero2.oct--------------
function sombrero2 (n)

  if (nargin != 1)
    usage ("sombrero (n)");

  if (n > 1)
    x = y = linspace (-8, 8, n)';
    [xx, yy] = meshgrid (x, y);
    r = sqrt (xx .^ 2 + yy .^ 2) + eps;
    z = sin (r) ./ r;

    mesh (x, y, z);
    error ("sombrero: number of grid lines must be greater than 1");

- ----------------

and tried "load sombrero2.oct", but octave says:

octave:4> load "sombrero2.oct"
error: load: sombrero2.oct: inconsistent number of columns near line 2
error: load: unable to extract matrix size from file `sombrero2.oct'

and denies.   However if I copy&paste this function in octave's
commandline prompt, sombrero2(n) works normally.  What's the difference
and how can I make octave read it?   octave's document isn't clear on
this to me...or am I missing anything?

I'm trying to plot sombrero-like graphics using polar coordinates in
x,y.  i.e. x=r*sin(theta); y = r*cos(theta); and z = (function of r and
theta); (it may look like x and y are reverse, but in my case it's
correct.)   I tried to define the ranges of r and theta, but it won't
work as expected.  It looks like 3 dimension graphics accepts only
lattice points of (x,y).  Then must I calculate r and theta from x,y?
It's a bit inconvenient..... but it's not so difficult and if there are
no other ways, I'll do so.

Thanks in advance!

- -Tetsuji
- --
Tetsuji 'Maverick' Rai
main page
PGP pubkey
PGP Key ID: 0x971E57CA
Key fingerprint: F790 28AF E95B 48C9 19AB  71FD 50B5 3572 971E 57CA
Aviation Jokes:
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla -


Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]