[Top][All Lists]

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

Re: function file question and plot using polar coordinates

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

Hash: SHA1

Shai Ayal wrote:
> Tetsuji "Maverick" Rai wrote:
> 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)");
>   endif
>   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);
>   else
>     error ("sombrero: number of grid lines must be greater than 1");
>   endif
> endfunction
> ----------------
> 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?
>> The way to do this is to save it as sombrero.m and than just type
>> sombrero
>> at the command line. what you did, "load sombrero.oct" tries to load
>> this file into a matrix as if it were a sequence of numbers.
Thank you!  It worked like a charm (at least it looked like a charm to
me:)).  Then octave looks for *.m file automatically.

- -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]