Constants that cannot be delete with CLEAR

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.

 채택된 답변

Matt J
Matt J 2023년 6월 4일
편집: Matt J 2023년 6월 4일

1 개 추천

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

추가 답변 (1개)

Dyuman Joshi
Dyuman Joshi 2023년 6월 4일
이동: Matt J 2023년 6월 4일

1 개 추천

You can use this command
clearvars -except VariblesNotToBeDeleted

댓글 수: 1

Pierre
Pierre 2023년 6월 4일
편집: Pierre 2023년 6월 4일
I little bit too long, imagine I have many constants.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

질문:

2023년 6월 4일

편집:

2023년 6월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by