形状変換

4 Ansichten (letzte 30 Tage)
sz
sz am 29 Nov. 2021
Beantwortet: Atsushi Ueno am 29 Nov. 2021
現在18×231250のデータが19個あります。
この18×231250×19のマトリックスを18×231250に形状変換したいです。
18×231250のデータを1個取り出すようにしたいです。(18×231250×1にする)
18×231250×19のデータをAなどと置いてスクリプトを送っていただきたいです。
reshapeを使うと思うのですが理解が出来ていないのでスクリプトも送っていただけると嬉しいです。
よろしくお願いいたします。

Akzeptierte Antwort

Atsushi Ueno
Atsushi Ueno am 29 Nov. 2021
A = zeros(18,231250,19); % 18×231250×19のマトリックスを18×231250に形状変換
for index = 1:size(A,3) % size(A,3)=19(Aの三番目の次元の数)なのでindex=1~19まで走査する
B = A(:,:,index); % 18×231250のデータ(index番目)を1個取り出す
size(B)
... % この後取り出した18×231250のデータを処理する
end
ans = 1×2
18 231250
ans = 1×2
18 231250
ans = 1×2
18 231250
ans = 1×2
18 231250
ans = 1×2
18 231250
ans = 1×2
18 231250
ans = 1×2
18 231250
ans = 1×2
18 231250
ans = 1×2
18 231250
ans = 1×2
18 231250
ans = 1×2
18 231250
ans = 1×2
18 231250
ans = 1×2
18 231250
ans = 1×2
18 231250
ans = 1×2
18 231250
ans = 1×2
18 231250
ans = 1×2
18 231250
ans = 1×2
18 231250
ans = 1×2
18 231250
>reshapeを使うと思うのですが
⇒配列の形状変換(変更)というと、変換前後の要素数が変わらない変換の事を言います。
今やりたい事は3次元の行列から2次元のスライス1枚を取り出す事で、要素数はn分の1に減ります。

Weitere Antworten (0)

Kategorien

Mehr zu 行列および配列 finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!