| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
remove(M, keys) erases all specified keys, and the values associated with them, from Map object M.keys can be a scalar key or a cell array of keys.
Using remove changes the count of the elements in the map.
Read more about Map Containers in the MATLAB Programming Fundamentals documentation.
Create a Map object containing the names of several US states and the capital city of each:
US_Capitals = containers.Map( ...
{'Arizona', 'Nebraska', 'Nevada', 'New York', ...
'Georgia', 'Alaska', 'Vermont', 'Oregon'}, ...
{'Phoenix', 'Lincoln', 'Carson City', 'Albany', ...
'Atlanta', 'Juneau', 'Montpelier', 'Salem'});
After checking how many keys there are in the US_Capitals map, remove the key-value pair with key name Oregon from it:
US_Capitals.Count
ans =
8
remove(US_Capitals, 'Oregon');
US_Capitals.Count
ans =
7Remove three more key-value pairs from the map:
remove(US_Capitals, {'Nebraska', 'Nevada', 'New York'});
US_Capitals.Count
ans =
4containers.Map, keys(Map), values(Map), size(Map), length(Map)isKey(Map),handle
![]() | rem | removets | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |