How to delete the nth element from all the variables in my workspace?

조회 수: 1 (최근 30일)
Hello
I would like to delete the nth element from all the variables in my workspace, which are all vectors of the same size. I tried playing with the "who" function but it didn't work, any ideas?
Many thanks in advance

채택된 답변

Thorsten
Thorsten 2015년 10월 21일
편집: Thorsten 2015년 10월 21일
x = whos;
n = 2;
for i=1:numel(x)
eval([x(i).name '(' int2str(n) ')=[];'])
end
  댓글 수: 4
Thorsten
Thorsten 2015년 10월 21일
편집: Thorsten 2015년 10월 21일
You could add a
if numel(x(i).name) >= n
to make the code more robust.

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by