Constants that cannot be delete with CLEAR

1 visualización (últimos 30 días)
Pierre
Pierre el 4 de Jun. de 2023
Editada: Pierre el 4 de Jun. de 2023
Simple,
I have some personal constants define in startup.m but every time I type CLEAR in the command window I loose them.
Is there a way to make some constants non deletable ?
Thank you.

Respuesta aceptada

Matt J
Matt J el 4 de Jun. de 2023
Editada: Matt J el 4 de Jun. de 2023
You could make the constants the Constant properties of a class. Then they can be reused even after issuing clear
classdef myconst
properties (Constant)
a=1;b=2;c=3
end
end
>> myconst.a
ans =
1
>> clear
>> myconst.b
ans =
2

Más respuestas (1)

Dyuman Joshi
Dyuman Joshi el 4 de Jun. de 2023
Movida: Matt J el 4 de Jun. de 2023
You can use this command
clearvars -except VariblesNotToBeDeleted
  1 comentario
Pierre
Pierre el 4 de Jun. de 2023
Editada: Pierre el 4 de Jun. de 2023
I little bit too long, imagine I have many constants.

Iniciar sesión para comentar.

Categorías

Más información sobre Software Development Tools en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by