Octave/Sombrero

From Coder Merlin
< Octave
Revision as of 13:43, 31 March 2022 by Chukwuemeka-tinashe (talk | contribs) (Created page with "== 3-D Sombrero Plot == {{ConsoleLine|octave:2>|tx {{Equal}} ty {{Equal}} linspace (-8, 8, 41);}} {{ConsoleLine|octave:3>|[xx, yy] {{Equal}} meshgrid (tx, ty);}} {{ConsoleLine|octave:4>|r {{Equal}} sqrt (xx .^ 2 + yy .^ 2) + eps;}} {{ConsoleLine|octave:5>|tz {{Equal}} sin (r) ./ r;}} {{ConsoleLine|octave:6>|mesh (tx, ty, tz);}} {{ConsoleLine|octave:7>|xlabel ("tx");}} {{ConsoleLine|octave:8>|ylabel ("ty");}} {{ConsoleLine|octave:9>|zlabel ("tz");}} {{ConsoleLine|octave:1...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder

3-D Sombrero Plot[edit]

octave:2> tx = ty = linspace (-8, 8, 41);

octave:3> [xx, yy] = meshgrid (tx, ty);

octave:4> r = sqrt (xx .^ 2 + yy .^ 2) + eps;

octave:5> tz = sin (r) ./ r;

octave:6> mesh (tx, ty, tz);

octave:7> xlabel ("tx");

octave:8> ylabel ("ty");

octave:9> zlabel ("tz");

octave:10> title ("3-D Sombrero Plot");

We can now print the plot to a file with:

octave:11> print -dpng sombrero.png

It may take a few seconds to produce the file; be patient.

It's necessary to adjust the file's permissions to enable web server access. This may easily be performed from within octave using the following command:

octave:12> system("chmod -R a+rX ~/www")

When the prompt returns, the file may be viewed in a browser. Every user has a personal URL. Your file may be viewed here: You must be logged in to view your personal URL.