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

1 回表示 (過去 30 日間)
Victor Lejona
Victor Lejona 2015 年 10 月 21 日
コメント済み: Victor Lejona 2015 年 10 月 21 日
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.
Victor Lejona
Victor Lejona 2015 年 10 月 21 日
Good idea, thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by