Clear variable from Memory in MATLAB Last Updated : 04 Jul, 2021 Comments Improve Suggest changes Like Article Like Report Clearing variables from memory, with the help of clearvars operation. The clearvars operation is used to clear the specified variables from memory or from the currently active workspace. Syntax:clearvars variables clearvars -except keepVariables Parameters: This function accepts a parameter. variables: These are the specified variables that are going to be cleared. Example 1 Matlab % MATLAB code for variables "x" and "y" % cleared from the memory and variable "z" % will be as it is. x = 5; % Initializing y = 10; z = 15; % Calling the clearvars operation over % the x and y variables clearvars x y % Getting the remaining variables whos Output: Example 2 Matlab % MATLAB code for all variables will be % cleared except "C" and "D". A = 5; % Initializing of variables B = 10; C = 15; D = 20; E = 25; % Calling the clearvars operation to % clear above variables except C and D clearvars -except C D % Getting the remaining variables whos Output: Comment More infoAdvertise with us Next Article Clear variable from Memory in MATLAB K Kanchan_Ray Follow Improve Article Tags : Software Engineering MATLAB MATLAB-programs Similar Reads Clear items from Memory in MATLAB In this article, we are going to discuss "Clearing items from Memory", in MATLAB which can be done using clear operation. The clear operation is used to clear the specified items from memory or from the currently active workspace. It is used to free up the system memory. Syntax: clear clear name1 . 4 min read Set environment variable in MATLAB Setting environment variables with the help of setenv() function. The setenv() function is used to set the specified value of an operating system environment variable. Here the environment variable "name" will be replaced with "value", where "name" and "value" is its parameters. Syntaxsetenv(name, v 1 min read Variable Names in MATLAB A variable is a named-memory location that stores different types of data which can be used to perform a specific set of operations. It can be thought of as a container that holds some value in memory. The Matlab workspace store all the variables being used during a session. This workspace not only 5 min read Global Variables in MATLAB Variables in programming are generally storage spaces to store a certain type of data. There are many types of variables, but two commonly used types are local and Global variables. Generally, each MATLAB function has its own local variables. But sometimes for the sake of programming, we need to cha 4 min read Set Variable Data Types in MATLAB There are many cases when a user has to import data into MATLAB script from various files. These file types could be .txt, .xlsx, .csv, .dat, etc. types. Now, each file type has its own method of defining data types. However, for computation purposes, MATLAB requires the data to be of numeric type, 3 min read Like