Tips for organizing variables in the workspace? Is there an option like "exlude capitalized variables" like python/spyder?

조회 수: 19 (최근 30일)
My script has a lot of variables. Many of these are created simply to make the code easier to debug so I don't have to chase endless delimiters. However this fills the workspace variables I don't actually care about and it's kind of a disaster to search through.
Introduction/Motivation
Here's a silly example that uses extraneous variables because it makes it easier to debug.
X0 = 0
Span = 5
Xorig = X0:x0+Span
x= Xorig + 3.3
y = x.^2; %easy to read what's going on in each line, but I don't really care about x0, span, xORIG etc
Here's a version that uses as few variables as possible but is slightly messier to debug.
x = 0+3.3:0+5+3.3
y = x.^2
This version slightly harder to read but has the advantage of not storing "X0", "Span", and "Xorig" as variables and cluttering the workspace.
Question
In Python/Spyder, it seems to be possible to choose exclude upper case variables from the variable explorer (see the answer to this question). A feature like this would be very nice in MATLAB but I have been unable to find one. Do people have recommendations for organizing the workspace in Matlab so it's less of a mess?
Screenshot from Anaconda Spyder:

답변 (2개)

Walter Roberson
Walter Roberson 2021년 8월 4일
The below code, when executed, creates a list of links, one for each lower-case variable name. When clicked, the variable will be opened in the variable browser.
The code could be enhanced to output a certain number per line, or a maximum length per line, which would probably be a good idea; this gives a framework that could be worked with.
abc = "hello";
X42 = 7;
def = [1 2 3];
LLV
function LLV
UVN = evalin('caller', "who('-regexp', '^[a-z]')");
UVNS = string(UVN);
fprintf('%s\n', "<a href=""matlab:openvar('" + UVNS + "')"">" + UVNS + "</a>")
end

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 8월 4일

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by