Difference between revisions of "Octave/Sombrero"

From Coder Merlin
(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...")
 
 
(One intermediate revision by one other user not shown)
Line 11: Line 11:
We can now print the plot to a file with:
We can now print the plot to a file with:
{{ConsoleLine|octave:11>|print -dpng sombrero.png}}
{{ConsoleLine|octave:11>|print -dpng sombrero.png}}
It may take a few seconds to produce the file; be patient.   
It might 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:
To enable web server access, you need to adjust the file's permissions. You can do this from within Octave using the following command:
{{ConsoleLine|octave:12>|system("chmod -R a+rX ~/www")}}
{{ConsoleLine|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: {{PersonalURL|path=sombrero.png}}
When the prompt returns, you can view the file in a browser. Every user has a personal URL. Your file can be viewed here: {{PersonalURL|path=sombrero.png}}
 
{{MerlinMultipageExperienceNavBar}}

Latest revision as of 12:21, 14 April 2022

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 might take a few seconds to produce the file; be patient.

To enable web server access, you need to adjust the file's permissions. You can do this from within Octave using the following command:

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

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