lundi 12 février 2018

Submatrix in matlab using random columns and loop

I have a $102 \ times 102$ matrix. I want to select square sub-matrices of orders from $2$ up to $8$ using random column numbers. Here is what I have done so far.

matt is the the original matrix of order $102 \times 102$.

ittr = 30
cols = 3;
for i = 1:ittr
   rr = randi([2,102], cols,1);
   mattsub = matt([rr(1) rr(2) rr(3)], [rr(1) rr(2) rr(3)]);
end

Question is: I have to extract matrices of different orders from 2 to 8. Using above code I would have to change $mattsub$ line every time I change $cols$. I believe it is possible to do with another loop inside but cannot figure out how. (Somehow MathJax doesn't seem to work ?). Thanks for the help.




Aucun commentaire:

Enregistrer un commentaire