Storing workspace variables that match the specified regular expressions.

How do we store workspace variables identifed using regular expressions.
Consider the following example below...
ex_1 = 5;
ex_2 = 3;
i_i = 4;
%if I do this
whos -regexp ^ex_[1]*|^i.\d+
Name Size Bytes Class Attributes ex_1 1x1 8 double ex_2 1x1 8 double
%it works
%but if I do this
s = whos(-regexp ^ex_[1]*|^i.\d+);
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
%it throws an error

댓글 수: 1

"It throws an error"
Note that storing meta-data in variable names makes code slow, complex, inefficient, buggy, and difficult to debug.

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

 채택된 답변

Fangjun Jiang
Fangjun Jiang 2022년 6월 7일
편집: Fangjun Jiang 2022년 6월 7일
see "doc whos"
s=whos('-regexp','^ex_[1]*|^i.\d+')

추가 답변 (0개)

카테고리

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

제품

릴리스

R2022a

질문:

2022년 6월 7일

댓글:

2022년 6월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by