Concatenating matrices in a file into another matrix

2 ビュー (過去 30 日間)
arun Dhillon
arun Dhillon 2020 年 1 月 14 日
コメント済み: arun Dhillon 2020 年 1 月 14 日
Hello,
I am having certain 1*3 matrices; all of them are stored in a file (p.mat). All of them are of size 1*3; (for ex P1=[1 2 3]; P3=[2 2 1]etc. What I want to do is to combine all separate 1*3 matrices into one n*3 matrix(NOTE: THE NO. OF ROWS IN p.mat file CHANGES).
Any suggestions would be greatly appreciated.
  1 件のコメント
Bob Thompson
Bob Thompson 2020 年 1 月 14 日
Where are the 1x3 matrices originating from? I personally do not know a way to do this without using bad coding practices, but it might be easier to capture the data on the front end, rather than the back.

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

採用された回答

Matt J
Matt J 2020 年 1 月 14 日
編集済み: Matt J 2020 年 1 月 14 日
For example,
>> p1=[1,2,3]; p2=[4 5 6]; p3=[7 8 9]; save p p1 p2 p3
>> A=cell2mat(struct2cell(load('p')))
A =
1 2 3
4 5 6
7 8 9
  1 件のコメント
arun Dhillon
arun Dhillon 2020 年 1 月 14 日
Matt J
Thanks alot for the help.It works very well

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by