[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: function file question and plot using polar coordinates
From: |
Shai Ayal |
Subject: |
Re: function file question and plot using polar coordinates |
Date: |
Wed, 11 Jan 2006 20:31:03 +0200 |
User-agent: |
Thunderbird 1.5 (Windows/20051201) |
Tetsuji "Maverick" Rai wrote:
-----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?
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.
#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.
I'm not sure about this one
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
-------------------------------------------------------------
-------------------------------------------------------------
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
-------------------------------------------------------------