Home > Software engineering >  Matlab matrix algorithm
Matlab matrix algorithm

Time:09-27

I generated a 24 * 7 matrix, want to be in the 24 arbitrary line extraction of 7 lines, these lines are not in order of submatrix extraction, but random extraction), so that you can get a lot of 7 * 7 square, each square for Ai, I want to do is to put a square matrix eigenvalue calculated, and then fill in turn into a new matrix,

CodePudding user response:

Fyi:
 # include & lt; stdio.h> 
# include & lt; Stdlib. H>
# include & lt; Time. H>
Int d [6];
Int I, n, a, b, t;
C, int j;
Void main () {
srand(time(NULL));
Printf (" shuffle 0.. N - 1 demo \ n ");
For (n=1; n<=5; N++) {/* (1 ~ 5 */
Printf (" _____n=% d_____ \ n ", n);
J=1;
For (c=1; C<=n; C + +) j=j * c;/* j for n! */
J *=n * 2;
For (c=1; C<=j; C + +) {/* test n * 2 * n! Time */
for (i=0; iFor (I=n; I> 0; I -) {/* disturb 0 ~ */n - 1
A=I - 1; B=rand () % I;
If (a! A=b) {t=d [a]; D [a] [b]=d; D [b]=t; }
}
Printf (" % 4 d: ", c);
for (i=0; iprintf("\n");
}
}
Printf (" shuffle 1.. N demo \ n ");
For (n=1; n<=5; N++) {/* (1 ~ 5 */
Printf (" _____n=% d_____ \ n ", n);
J=1;
For (c=1; C<=n; C + +) j=j * c;/* j for n! */
J *=n * 2;
For (c=1; C<=j; C + +) {/* test n * 2 * n! Time */
For (I=1; i<=n; I++) d [I]=I;/* fill in 1 ~ n */
For (I=n; I> 1; I -) {/* disturb 1 ~ n */
A=I; B=rand () % I + 1;
If (a! A=b) {t=d [a]; D [a] [b]=d; D [b]=t; }
}
Printf (" % 4 d: ", c);
For (I=1; i<=n; I++) printf (" % d ", d [I]);
printf("\n");
}
}
}
  • Related