Site icon TestingDocs.com

Octave clear command

Overview

In this tutorial, we will learn about the Octave clear command. The clear command deletes the variables that match the pattern to free memory for the current Octave session.

We can use the command at the Command Window prompt or in the Octave script.

Syntax

To clear all the variables in the Octave session.

>> clear

To clear the variables that match the pattern in the Octave session. The PATTERN may contain the following special characters.

>> clear [options] PATTERN

Some of the characters and the descriptions are as follows:

Character
Description
 

‘?’

Match any single character
 

‘*’

Match zero or more characters
‘[ LIST ]’

 

Match the list of characters specified by the LIST

 

Example

# clear command

The simple clear command clears all the variables in the Octave session.

In this example, we will define three variables at the command window prompt.

>> website = “TestingDocs.com”;
>> area = 32.50;
>> radius = sqrt(area/pi);
>> who
Variables visible from the current scope:

area radius website

Check the values by typing the name of the variable at the command prompt

>> website
website = TestingDocs.com
>> area
area = 32.500
>> radius
radius = 3.2164
>>

Issue the clear command.

>> clear

Check with the who or whos command. All the variables defined will be cleared.

# clear command with pattern

Let’s clear the command with a character matching pattern. We will define two variables foo and bar. We will clear the variable bar with the clear command.

>> foo=’foo’;
>> bar=’bar’;
>> who
Variables visible from the current scope:

bar foo

>> clear b*r
>> who
Variables visible from the current scope:

foo

 

Octave has a special clc() command to clear the command window terminal screen. The clc command is used to clear the command window and takes the cursor to the top left corner. The clc command will not delete the variables.

Octave Tutorials

Octave Tutorial on this website can be found at:
https://www.testingdocs.com/octave-tutorial/

More information on Octave can be found on the official website:
https://www.gnu.org/software/octave/index

Exit mobile version