Creating a tensor from multiple matrices

71 ビュー (過去 30 日間)
Charity Rose
Charity Rose 2019 年 7 月 29 日
回答済み: Abhilash Padma 2019 年 8 月 2 日
I have four matrices I am trying to combine into a tensor. I.e I want to turn four matrices of 155 x 275 into 155x275x4 and cumulatively add them together. This is what I have so far, please can someone help me? Thanks Charity
%% IMPORTING THE MATRICES
U1= importdata ('U1.txt');
U2= importdata ('U2.txt');
U3= importdata ('U3.txt');
U4= importdata ('U4.txt');
%% CREATING A TENSOR
n=4;
tensor1= zeros (155,275,n); %setting matrix size
%% CUMULATING VALUES
for i=1:n
tensor1(:,:,i)= what should go here??
end
CumulativeU=cumsum(tensor1,3);

回答 (1 件)

Abhilash Padma
Abhilash Padma 2019 年 8 月 2 日
You can use the “cat” function to create a tensor.
cat(3,U1,U2,U3,U4);
Refer the following link for more information: https://www.mathworks.com/help/matlab/ref/cat.html

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by