create a matrix d of size 4x6 filled with consecutive integers starting from 1. create the matrix d in matlab and reshape matrix d into a 2x12 matrix write the code and its output in matlab

main.m
% Create a 4x6 matrix filled with consecutive integers starting from 1
d = reshape(1:24, 4, 6);

% Reshape matrix d into a 2x12 matrix
reshaped_d = reshape(d, 2, 12);

% Display output
disp(d);
disp(reshaped_d);
212 chars
10 lines

Output:

main.m
d =

     1     5     9    13    17    21
     2     6    10    14    18    22
     3     7    11    15    19    23
     4     8    12    16    20    24

reshaped_d =

     1     3     5     7     9    11    13    15    17    19    21    23
     2     4     6     8    10    12    14    16    18    20    22    24
314 chars
12 lines

related categories

gistlibby LogSnag