How to automatically create variables which are column extracts from a matrix

前端 未结 4 518
被撕碎了的回忆
被撕碎了的回忆 2021-01-20 11:34

I have an n*n matrix and I want to extract every 3 columns and keep the result in different variables.

I know that it is possible to do it in this way:

4条回答
  •  清酒与你
    2021-01-20 12:03

    Don't create dynamic variables. If really needed, reshape A into a 3D array as follows:

    A = reshape(A,size(A,1),3,[]); 
    %where 3 is the number of columns you want to extract at a time
    

提交回复
热议问题