[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 |
-----BEGIN PGP SIGNED MESSAGE-----
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)");
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?
#2
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 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
iD8DBQFDxU61ULU1cpceV8oRAn+xAJ4ol9YnP7nU5pKCS8Ogw/H7iyOyPQCfWny/
OI7uIgvfP02wkm4FhojKiJs=
=soER
-----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
-------------------------------------------------------------
- function file question and plot using polar coordinates,
Tetsuji \"Maverick\" Rai <=