converting column of data to matrix plane

조회 수: 1(최근 30일)
Hussein Kokash
Hussein Kokash 2023년 1월 17일
답변: Hussein Kokash 2023년 1월 17일
I have a data file that has the following shape:
x y z U V W
-0.026 -0.108 0.1 -4.4822257E-02 5.4139438E-01 1.1798316E-10
-0.025 -0.108 0.1 -4.9442114E-02 6.5561204E-01 6.8515270E-11
-0.024 -0.108 0.1 -1.2523164E-01 5.4269489E-01 -9.1736493E-11
-0.023 -0.108 0.1 -1.9679146E-01 4.1256618E-01 -2.4873436E-10
-0.022 -0.108 0.1 -2.4292102E-01 2.9788454E-01 -3.5452176E-10
where it represents the velocity values of a plane (67*67), every 67 row y changes.
I want to convert a single column of the velocity value (U, V or W) to a matrix that represents the actual plane (67*67), by taking every 67th line and paste it in a new row.
Any way to do it? the original data file is included if needed.
Thank you!!!

채택된 답변

Hussein Kokash
Hussein Kokash 2023년 1월 17일
This is an example:
% Define the column
A = [1;4;7;10;13;16];
% Define the value of n n = 3;
% Initialize an empty matrix to store the new submatrices B = [];
% Loop through the rows of the column A
for i = 1:n:size(A,1)
% Extract every nth row of the column A
subcol = A(i:i+n-1);
% Convert the subcolumn to a matrix
submat = reshape(subcol,n,1);
% Append the submatrix to the new matrix B
B = [B submat];

추가 답변(0개)




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by