필터 지우기
필터 지우기

How can I asign columns of a matrix to different matrixes?

조회 수: 1 (최근 30일)
David Kaeser
David Kaeser 2020년 10월 13일
댓글: David Kaeser 2020년 10월 13일
Hi I would like to a large data matrix in different matrices. The data matrix is a 4 * 85932 (558*154) matrix where I want to asign each column to a different new matrix with the dimension of (558*154) and save it to the workspace. I tried to write following function to achieve that and than to run it from the command window. I only get a output in the command window but the matrices are not saved in the workspace.
Function
function [x, y, z, Vx, Vy] = matrix_generation(data)
%MATRIX_GENERATION returns the x, , z, Vx, vy as 558*154 matrixes
% splits each collum in 154 columns with each has 558 data
% the data matrix has 5 columns
for i= 1:5
q = zeros(558,154);
% each column has 154*558 rows
for j=1:154
for a = 1:558
q(a,j) = data(j*a,i);
end
end
if (i ==1)
x = q;
elseif (i ==2)
y = q;
elseif (i ==3)
z = q;
elseif (i ==4)
Vx = q;
else
Vy = q;
end
end
end
  댓글 수: 2
KSSV
KSSV 2020년 10월 13일
Each column has 8470 rows....how you can get them into dimension 558*154?
558*154 ~= 8470.
David Kaeser
David Kaeser 2020년 10월 13일
Sorry I meant 85932 rows

댓글을 달려면 로그인하십시오.

채택된 답변

madhan ravi
madhan ravi 2020년 10월 13일
permute(reshape(matrix, 154, 558, []), [2, 1, 3])
  댓글 수: 3
madhan ravi
madhan ravi 2020년 10월 13일
matrix is your data
David Kaeser
David Kaeser 2020년 10월 13일
Ok thanks a lot. I was not sure how to store the result in my different matices but managed it now. Thanks again it worked now perfectly.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by