How can I covert 10x10 matrix to a 10x10x1 matrix?

4 ビュー (過去 30 日間)
David Parks
David Parks 2016 年 5 月 20 日
編集済み: per isakson 2016 年 5 月 20 日
I'm writing a matrix to an HDF5 file, I've created the file as a matrix sized 10x10x500.
I have a 10x10 matrix, and want to iteratively write out each 10x10 matrix to my HDF5 file, but h5write complains that my 10x10 matrix needs to be a 10x10xN sized matrix.
Is there a way to change a 10x10 matrix to a 10x10x1 so the dimensions match for writing with h5write? None of: reshape, permute, or cat work.
I could cache all 500 10x10 matrices in memory and write them out, but my real-life example is much bigger than 10x10x500. It'd be easier if I could do it iteratively.
  2 件のコメント
John D'Errico
John D'Errico 2016 年 5 月 20 日
編集済み: John D'Errico 2016 年 5 月 20 日
A 10x10 matrix is ALREADY a 10x10x1 matrix. In fact, it is a 10x10x1x1x1x1x1x1... matrix. Those singleton dimensions go on to infinity.
A = rand(10,10);
size(A,3)
ans =
1
size(A,12)
ans =
1
Ok, infinity is a long walk.
per isakson
per isakson 2016 年 5 月 20 日
編集済み: per isakson 2016 年 5 月 20 日
There is something is wrong with the way you call h5create and h5write - I guess.

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

回答 (0 件)

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by