Concatenation of three-dimensional arrays

2 ビュー (過去 30 日間)
Richard Wood
Richard Wood 2020 年 2 月 28 日
編集済み: Stephen23 2020 年 3 月 2 日
Hello everyone,
I am trying to concatenate two three-dimensional arrays inside of a double for loop:
for i=1:length(Temperature_max)
for j=1:length(Hy1_values)
Hy1(:,j,i)=ones(length(time_first_interval),1).*Hy1_values(j); % A/m
Hy2(:,j,i)=zeros(length(time_second_interval),1); % A/m
Hy(:,j,i)=vertcat(Hy1(:,j,i),Hy2(:,j,i));
end
end
Obviously vertcat does not work. Any suggestion?
  6 件のコメント
Stephen23
Stephen23 2020 年 3 月 2 日
編集済み: Stephen23 2020 年 3 月 2 日
This cat call does absolutely nothing, because one array concatenated with nothing else simply returns the one array:
cat(2,[Hy1(:,j,i);Hy2(:,j,i)])
You already concatenated two arays togther (vertically) using square brackets to give one array, and then passed that one array to the totally superfluous cat call, which simply returns that same one array. Not much point in that.
Note that these are equivalent:
[A;B]
cat(1,A,B)
If you want to concatenate vertically, then you can use either.
Guillaume
Guillaume 2020 年 3 月 2 日
Note that these are equivalent:
and
vertcat(A, B)

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

回答 (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