MATLAB: How to remove column x from all variables in the workspace

worspace

I do nor understand how to loop through variale in a workspace and perform the same thing to each of them.
I a sure it is simple…

Best Answer

Option n_by_Walter+1:
A.a=[1,1,1,1;2,2,2,2;3,3,3,3];
A.b=[1,1,1,1;2,2,2,2;3,3,3,3];
A.c=[1,1,1,1;2,2,2,2;3,3,3,3];
A.d=[1,1,NaN,1;2,2,2,2;3,3,3,3];
data=struct2cell(A);
data=cat(3,data{:});
L=any(isnan(data),3);
col_with_NaN=any(L,1);
data(:,col_with_NaN,:)=[];
Storing into a 3D array gives you a lot of flexibility without a lot of call to complex (and sometimes slow) functions like structfun.