MATLAB: For loop to extract every 3rd column out of matrix and assign as variable name

for loopiterationmatrix

I have a matrix that is 6001 x 72. I want to iterate through the matrix to extract every 3rd column, from 1:72, and assign it to a variable name, such as X1, X2,…,X24. How can I do this?
I have tried a for loop, but I keep getting error messages. I am a beginner in Matlab.
Thanks!

Best Answer

Do not do this! This will only lead to headaches downstream in your code for processing these variables (you will need to use more eval( ) statements etc) and will be a nightmare to debug. There are much better alternatives. E.g.,
Related Question