Do one action to multiple arrays
조회 수: 1(최근 30일)
José-Luis 2017년 9월 19일
편집: José-Luis 2017년 9월 19일
The answer would be a slight adaptation of "don't use dynamic variable names" with the added issue of not being able to use a loop to generate variable names.
The short answer is: you're still going to need to specify which variables you need to delete an element from.
You can do that through a function that takes a variable number of arguments and deletes the second element in all of them. You'd still need to specify all the variables somehow.
In fact, whatever you do, you need to get the variable names. That could be through an introspective function like who and it's bound to be pretty ugly.
The sane way to do it is either put everything in an array if the dimensions are consistent or in a cell array if they are not. Then what you are asking becomes trivial.