Preallocating matrix with a numeric trend
이전 댓글 표시
Hello all,
I manually wrote out the following matrix, IMiteration (since I didn't know how to code for it):
%%Define I1, I2 selection matrix (since not all combinations with higher
% keV at base is meaningful)
Mx1 = [40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 ...
45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 ...
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 ...
55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 ...
60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 ...
65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 ...
70 70 70 70 70 70 70 70 70 70 70 70 70 70]';
Mx2 = [45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 ...
50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 ...
55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 ...
60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 ...
65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 ...
70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 ...
75 80 85 90 95 100 105 110 115 120 125 130 135 140]';
IMiteration = [Mx1 Mx2];
Now, instead of having a step size of 5 in Mx2, I would like the step size to be 2 instead. So for example, the first 51 rows of the final product will have 40 in column 1, and 42:2:140 in column 2. The next 50 will have 42 in column 2, and 44:2:140 in column 2, and so on. Is there a smarter way to generate this matrix? Thanks.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!