From help-request at octave dot org Wed Jan 11 12:56:02 2006 Subject: Re: function file question and plot using polar coordinates From: "Tetsuji \"Maverick\" Rai" To: Shai Ayal CC: help at octave dot org Date: Thu, 12 Jan 2006 03:54:17 +0900 -----BEGIN PGP SIGNED MESSAGE----- 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 http://maverick6664.bravehost.com/ PGP pubkey http://mav.atspace.com/maverick31337_at_gmail_dot_com.txt PGP Key ID: 0x971E57CA Key fingerprint: F790 28AF E95B 48C9 19AB 71FD 50B5 3572 971E 57CA Aviation Jokes: http://www.geocities.com/tetsuji_rai/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFDxVRZULU1cpceV8oRAlYiAKCVXso7x40VhWp/2VCmCLUXrT4fhACeOrNH 9YTyteNGMgglbT/+j2p8GgQ= =1IA0 -----END PGP SIGNATURE----- ------------------------------------------------------------- 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 -------------------------------------------------------------