MATLAB: Same operation on all matrices from workspace

matricesworkspace

I have a large number of matrices in my workspace and I would like to perform the same operation on all of them. any idea on how to do this?

Best Answer

Let me guess, the matrices on which you want to operate are named A1, A2, A3, ... or have a similar pattern? If so, DON'T DO THAT.
If all the variables have the same size, concatenate them into an N-dimensional array and iterate over the dimension in which you concatenated them. If they don't, store them in a cell array or fields of a struct array and use cellfun, structfun, or arrayfun.