What is the Octave Workspace
In this guide, I will explain what the Octave workspace is.
The workspace is the area where all the objects you have used in your calculations during the session are stored. These include commands, global variables, local variables, and their respective values.
For instance, try typing 3+5 on the command line and then press enter.
>> 3+5
Octave computes the sum and records the result in the variable 'ans', which is then displayed:
ans = 8
The term 'ans' is a global variable that stores the values of the most recent operations performed in the command prompt.
What is a global variable? It is a variable that can be accessed from any workspace in Octave.
You can view the 'ans' variable in the workspace, typically located in the left panel of Octave.
If you don't see the workspace, click on Window in the top menu.
Then select Show Workspace or press the Ctrl+Shift+3 keys.
Local variables in Octave
In the workspace window, you can find all the local variables that you declare or use in your current session of work.
What is a local variable? A variable is called local when it can only be accessed within a particular Octave environment and not by others. For instance, local variables in a function can only be accessed within the function.
For example, let's define a variable called "test" and assign it the value of 5. Then hit enter.
>> test = 5
Now, you can see the variable "test" in the workspace.
How to clear the workspace in Octave?
To delete all data from the workspace, simply type the command 'clear' in the command line.
clear
This command removes both variables and their assigned values.
It allows you to start a new work session without having to restart Octave.
If you like this Octave lesson by Nigiara, keep following us.