フィルターのクリア

Create a Single Array From 3 different one

1 回表示 (過去 30 日間)
Fabio Taccaliti
Fabio Taccaliti 2022 年 4 月 29 日
コメント済み: Jan 2022 年 5 月 2 日
Hello,
I have 3 arrays x, y and z (each 14x4) and I want to create from these an array tot (56x3).
It should be composed taking for the first cell, the first element of array x, in the second one, the first element of array y and in the third one, the first element of array z and so on for all the elements in the sub-arrays (going row by row), how can I do it?
Basically the sub-arrays contains all the coordinated of a set of point (divinded in x, y and z) and I want to create an array with all the points and the different coordinates on the 3 columns (x, y and z).
I think I have to use 3 loops for each array, but how?
Thanks in advance

回答 (1 件)

Jan
Jan 2022 年 4 月 29 日
編集済み: Jan 2022 年 4 月 29 日
I'm not sure what "going row by row" means. Maybe
x = rand(14, 4);
y = rand(14, 4);
z = rand(14, 4);
xt = x.';
yt = y.';
zt = z.';
result = [xt(:), yt(:), zt(:)]
% or:
result = [x(:), y(:), z(:)]
  2 件のコメント
Fabio Taccaliti
Fabio Taccaliti 2022 年 4 月 29 日
編集済み: Fabio Taccaliti 2022 年 4 月 29 日
Hi Jan, thanks for the answer.
With row by row I mean that after I finish to concatenate the fourth element of array x, y and z the algorithm should go in the second row and start again with the concatenation and so on. Let me know if now is more clear.
Regarding the code that you posted I get the following error, I think is due to the semicolon instead of comma
Dimensions of arrays being concatenated are not consistent.
Jan
Jan 2022 年 5 月 2 日
@Fabio Taccaliti: The code I have posted does not produce this error. Then the cause of the problem must be a part of your code. If you post your code, it would be possible to fix the problem.

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

カテゴリ

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

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by