Working with Octave on Fedora 26

Octave is a free alternative to Matlab to process numerical computation that offers built-in plotting and visualization tools to evaluate the behaviour or formulas and powerful equations. According with its official Website, it is multi platform and it also contains many compatible scripts with Matlab.

It is useful in the academic field to students, teachers and researchers to demonstrate and make interpretations of their calculations graphically.

Launching Octave

Using a terminal on Fedora 26, you might type octave to start its use. In case you do not have it installed, a message to ask you to install is going to be displayed. Then you could type y or Y to allow Octave installation.

You might also want to check what version of Octave you have installed:

 

Graphing a Trigonometric Function

To graphic the basic sine function, type the following commands in the interactive mode, which is presented with the prompt >>

>> x = -10:0.1:10;
>> plot (x, sin (x));

After an enter, a figure of the sine function will appear with the range and parameters previously defined (-10,10). The fine of the graphic is set with 0.1.

 

 

 

 

 

 

 

 

 

 

 

 

Formatting the axes on a graph

You might want to add axes in the graphic for a better explanation. In this case we can set the labels of both axes by defining the range of X and the value of Y

>> xlabel ("-10 ≤ x ≤ 10");
>> ylabel ("Y = sin (x)");

Click on the Refresh button to update the graphic of the sine formula:

Formatting numeric values and a title on a graph

Locate points where slope becomes most steep is important to detect in functions to explain. In this case we are going to draw two points in 1 and 6:

>> text(1,sin(1),'This is my Point')
>> text(6,sin(6),'This is another Point')

Then you can find the position of the points relative to the sine function:

 

 

 

 

 

 

 

 

 

 

 

Now we might add a title on this graphic with:

>> title('Sine Wave')

Adding a second trigonometric

To add another formula in the same graphic, you might type figure to create a new figure. Then, we are going to draw the cos function to plot it later:

>> figure
>> z = cos(x);
>> plot(x,z);

 

 

 

 

 

 

 

 

 

 

 

Now, we can present them together by using the hold on command and then call the sine function as it was plotted previously:

>> hold on
>> plot(x,sin(x));

 

 

 

 

 

 

 

 

 

 

 

Fine tuning to give the final touch

Colours can , width and a legend can be added to present our work in an article. Please apply the following commands to have the last draft:

>> plot (x,sin(x),'b', 'LineWidth',4);
>> plot (x,z,'r', 'LineWidth',4);
>> legend('cosine','sine')
>> title('Sine and Cosine Wave on Fedora 26')

 

 

 

 

 

 

 

 

 

 

 

You can also define maths elements (matrix, equations or vectors) to work with other values and equations to finally plot them in a 2D or 3D graphic.

About Julita Inca

System Engineering degree at UNAC, Computer Science Masters at PUCP, High Performance Masters at University of Edinburgh, Winner OPW GNOME 2011, GNOME Foundation member since 2012, Fedora Ambassador since 2012, winner of the Linux Foundation scholarship 2012, Linux Admin at GMD 2012, IT Specialist at IBM 2013. Academia experience in lecturing at PUCP, USIL and UNI Peru (2010-2018). HPC intern at ORNL 2018. HPC Software Specialist at UKAEA since 2020. Tech Certifications: RHCE, RHCSA, AIX 6.1, AIX 7 Administrator, and ITILv3. Leader of LinuXatUNI Community, Creator of the "Mujeres Imperfectas | I'm perfect woman" channel, Reviewer of the Technological Magazine of ESPOL-RTE, Online trainer at BackTrackAcademy, blogger, photographer, IT-Linux-HPC-science worldwide speaker, graphic designer, researcher, content creator, press communicator... a simple mortal, just like you!
This entry was posted in τεχνολογια :: Technology. Bookmark the permalink.

Leave a comment