How can I change the way Matlab fills in my matrix?

1 回表示 (過去 30 日間)
Anna M
Anna M 2019 年 4 月 9 日
コメント済み: A. Sawas 2019 年 4 月 9 日
My problem is that I have a 91x1147 matrix of velocity data (variable A) for 1147 points in a box size 31x37 at 91 different frequencies, and I also have a 91x1 matrix of frequency data (variable f) that corresponds to each row of the 91x1147 matrix. I have tried to reshape the file so that my new matrix is 31x37x91, but the resulting matrix lists the velocities down each column, and I need it to be listed starting across the rows, then on to the next row.
load('filename.mat', 'filename')
A = abs(filename(:,2:end));
f = abs(filename(:,1));
B = zeros(31,37,91);
for i = 1:length(f)
B(:,:,i) = reshape(A(i,:),31,37);
end
I am not allowed to upload the file I am working with, but if anyone could possibly help, that would be great! For visual purposes, in the code below, the C1 matrix is how the above "B" matrix looks, in terms of the way the numbers are ordered. I want "2" to be the first number in column 2, "3" to be the first number in column 3, and so on.
C = [1:1147];
C1 = reshape(C, 31,37);
Thanks!!

採用された回答

A. Sawas
A. Sawas 2019 年 4 月 9 日
B(:,:,i) = reshape(A(i,:),37,31)';
  3 件のコメント
Anna M
Anna M 2019 年 4 月 9 日
I kept it as 31, 37 but the ' symbol is what I needed. I am very rusty in Matlab.
A. Sawas
A. Sawas 2019 年 4 月 9 日
Glad it worked out

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by