フィルターのクリア

Data rearrangement inside matrices

1 回表示 (過去 30 日間)
Al Ne
Al Ne 2023 年 4 月 1 日
コメント済み: Al Ne 2023 年 4 月 2 日

Hello!
I am working on data preparation for deep learning. Let's say i have A = 0 variable containg time value, B = [0 0; 0.1 0.1; 0.2 0.2] matrix containing X-axis and Y-axis coordinates and C = [10 20 30; 40 50 60; 70 80 90] matrix containing function values. I need to store the data in an array D where the first column will contain time, the second column will contain X-axis values, the third column will contain Y-axis values and the fourth column will contain function values. It can be manually done pretty simple as
D(1:9,1)=A;
D(1:3,2)=B(1);
D(4:6,2)=B(2);
D(7:9,2)=B(3)
D(1:3,3)=B(1:3);
D(4:6,3)=B(1:3);
D(7:9,3)=B(1:3);
D(1:3,4)=C(1,1:3);
D(4:6,4)=C(2,1:3);
D(7:9,4)=C(3,1:3);
However, in reality there will be much more data. Hence, manual filling is inefficient. Is there any function to automize this procedure? Or should i create the for loops?
Thank you,
Alex

  2 件のコメント
Vilém Frynta
Vilém Frynta 2023 年 4 月 1 日
I would say it depends on :
  • how are your original data stored
  • how much more data will come (and where).
If you know where the new data will come in your array D, then you can take that into consideration when trying to automate this process. It also depend on how does your array D look like right now, and if there are some 'rules' that (for example, time is always in the first column, etc.) you can follow. If yes, it's quite automat-able.
Al Ne
Al Ne 2023 年 4 月 2 日
Thank you for your response! I think the final array will contain millions of elements

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

採用された回答

Atsushi Ueno
Atsushi Ueno 2023 年 4 月 1 日
移動済み: Atsushi Ueno 2023 年 4 月 1 日
A = 0; % variable containg time value
B = [0 0; 0.1 0.1; 0.2 0.2]; % matrix containing X-axis and Y-axis coordinates
C = [10 20 30; 40 50 60; 70 80 90]; % matrix containing function values
C = C';
D = [repelem(A,9,1), repelem(B(1:3)',3,1), repmat(B(1:3)',3,1), C(:)]
D = 9×4
0 0 0 10.0000 0 0 0.1000 20.0000 0 0 0.2000 30.0000 0 0.1000 0 40.0000 0 0.1000 0.1000 50.0000 0 0.1000 0.2000 60.0000 0 0.2000 0 70.0000 0 0.2000 0.1000 80.0000 0 0.2000 0.2000 90.0000
  1 件のコメント
Al Ne
Al Ne 2023 年 4 月 2 日
Many thanks!

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

その他の回答 (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